Fix
This commit is contained in:
parent
e80436be5a
commit
017d8eabcb
44
booking.py
44
booking.py
|
@ -742,13 +742,15 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
pass
|
||||
|
||||
@classmethod
|
||||
def get_grouped_invoices(cls, folios, kind=None, party=None):
|
||||
def get_grouped_invoices(cls, folios, kind=None, party=None, charges=[]):
|
||||
res = {}
|
||||
for folio in folios:
|
||||
bk = folio.booking
|
||||
price_list = bk.price_list
|
||||
agent_id = bk.channel.agent.id if bk.channel else bk.agent
|
||||
for ch in folio.charges:
|
||||
if charges and ch.id not in charges:
|
||||
continue
|
||||
if ch.invoice_line:
|
||||
continue
|
||||
if kind == 'only_products' and ch.kind == 'accommodation':
|
||||
|
@ -970,7 +972,9 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
print(e)
|
||||
|
||||
@classmethod
|
||||
def create_invoice(cls, booking_id, folios_ids, party_id=None, kind=None):
|
||||
def create_invoice(
|
||||
cls, booking_id, folios_ids, party_id=None,
|
||||
kind=None, charges=None):
|
||||
pool = Pool()
|
||||
Folio = pool.get('hotel.folio')
|
||||
Party = pool.get('party.party')
|
||||
|
@ -983,7 +987,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
invoice = {}
|
||||
party = Party(party_id)
|
||||
|
||||
invoice_to_create = cls.get_grouped_invoices(folios, kind, party)
|
||||
invoice_to_create = cls.get_grouped_invoices(
|
||||
folios, kind, party, charges)
|
||||
if not invoice_to_create:
|
||||
return
|
||||
|
||||
|
@ -2484,6 +2489,32 @@ class BillBookingStart(ModelView):
|
|||
('id', 'in', Eval('parties')),
|
||||
])
|
||||
parties = fields.Many2Many('party.party', None, None, 'Parties')
|
||||
charges = fields.Many2Many('hotel.folio.charge', None, None, 'Charges',
|
||||
domain=[
|
||||
('id', 'in', Eval('targets')),
|
||||
],
|
||||
states={
|
||||
'invisible': Eval('kind') != 'only_products',
|
||||
})
|
||||
targets = fields.Function(fields.Many2Many('hotel.folio.charge',
|
||||
None, None, 'Targets'), 'on_change_with_targets')
|
||||
|
||||
@fields.depends('kind')
|
||||
def on_change_with_targets(self, name=None):
|
||||
active_id = Transaction().context.get('active_id', False)
|
||||
Folio = Pool().get('hotel.folio')
|
||||
folios = Folio.search_read([
|
||||
('booking', '=', active_id),
|
||||
('charges.invoice_line', '=', None),
|
||||
], fields_names=['charges'])
|
||||
res = []
|
||||
for folio in folios:
|
||||
charges = folio.get('charges', None)
|
||||
if not charges:
|
||||
continue
|
||||
res.extend(list(charges))
|
||||
print("folios ....", res)
|
||||
return res
|
||||
|
||||
|
||||
class BillBooking(Wizard):
|
||||
|
@ -2534,7 +2565,12 @@ class BillBooking(Wizard):
|
|||
|
||||
kind = self.start.kind
|
||||
party_id = self.start.party.id if self.start.party else bk.party.id
|
||||
Booking.create_invoice(bk.id, folios_ids, party_id=party_id, kind=kind)
|
||||
charges = None
|
||||
if self.start.charges:
|
||||
charges = [charge.id for charge in self.start.charges]
|
||||
Booking.create_invoice(
|
||||
bk.id, folios_ids, party_id=party_id, kind=kind, charges=charges
|
||||
)
|
||||
# Moved to create invoice method
|
||||
# Booking.concile_charges([bk])
|
||||
# Booking.check_finished([bk])
|
||||
|
|
|
@ -7,4 +7,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="party"/>
|
||||
<field name="party" widget="selection"/>
|
||||
<field name="parties" invisible="1"/>
|
||||
<field name="charges" colspan="4"/>
|
||||
<field name="targets" invisible="1"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue