Add analytic to charges

This commit is contained in:
oscar alvarez 2022-11-21 12:30:51 -05:00
parent 48826ae1eb
commit dfa9014142
7 changed files with 30 additions and 15 deletions

View File

@ -603,6 +603,7 @@ class Booking(Workflow, ModelSQL, ModelView):
'origin': str(cha.folio),
'taxes': cha.folio.taxes,
'taxes_exception': bk.taxes_exception,
'analytic_account': cha.analytic_account,
}
@classmethod
@ -721,6 +722,11 @@ class Booking(Workflow, ModelSQL, ModelView):
'taxes': [('add', line['taxes'])],
'origin': line['origin'],
}
if line.get('analytic_account', None):
new_line['analytic_accounts'] = [('create', [{
'account': line['analytic_account'].id,
'root': line['analytic_account'].root.id,
}])]
return new_line
def do_moves(self):

View File

@ -52,7 +52,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="view" ref="booking_view_form"/>
<field name="act_window" ref="act_booking_form"/>
</record>
<!-- <record model="ir.action.act_window.domain" id="act_booking_form_domain_offer">
<record model="ir.action.act_window.domain" id="act_booking_form_domain_offer">
<field name="name">Offer</field>
<field name="sequence" eval="10"/>
<field name="domain" eval="[('state', '=', 'offer')]" pyson="1"/>
@ -80,7 +80,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="sequence" eval="90"/>
<field name="domain" eval="[]" pyson="1"/>
<field name="act_window" ref="act_booking_form"/>
</record> -->
</record>
<menuitem parent="menu_hotel" sequence="10" icon="hotel-booking"
action="act_booking_form" id="menu_booking_form"/>

View File

@ -428,12 +428,6 @@ class Folio(ModelSQL, ModelView):
moves.append(charge.move.id)
return moves
# def create_invoice(self, kind=None):
# pool = Pool()
# Booking = pool.get('hotel.booking')
# Booking.create_invoice([self], kind)
# Booking.check_finished([self.booking])
def get_unit_price_w_tax(self, name=None):
Tax = Pool().get('account.tax')
res = self.unit_price or 0

View File

@ -102,5 +102,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_missing_guest">
<field name="text">It missing guest in booking "%(number)s"!</field>
</record>
<record model="ir.message" id="msg_services_not_confirmed">
<field name="text">Services with the same kind but it isn't confirmed!</field>
</record>
</data>
</tryton>

View File

@ -246,15 +246,16 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
raise UserError(
gettext('hotel.msg_room_not_occupied', s=self.room.name)
)
elif len(folios) > 1:
raise UserError(
gettext('hotel.msg_multiple_rooms_active', s=self.room.name)
)
# elif len(folios) > 1:
# raise UserError(
# gettext('hotel.msg_multiple_rooms_active', s=self.room.name)
# )
# if not folios:
# return
folio = folios[0]
# folio = folios[0]
folio = self.folio
invoice_to = None
if folio.charges_blocked:
@ -264,6 +265,10 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
if folio.booking.channel:
invoice_to = self.folio.main_guest.id
analytic_account = None
if self.service.space:
analytic_account = self.service.space.analytic_account.id
record = {
'folio': self.folio.id,
'date_service': self.service.service_date,
@ -274,6 +279,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
'unit_price': self.product.template.list_price,
'product': self.product.id,
'to_invoice': True,
'analytic_account': analytic_account,
'state': '',
}
charge, = FolioCharge.create([record])
@ -348,6 +354,12 @@ class CreateDailyServices(Wizard):
folios = Folio.search(dom)
services = Service.search_read([
('state', '=', 'open'),
('kind', '=', kind.id),
])
if services:
raise UserError(gettext('hotel.msg_services_not_confirmed'))
lines_to_create = []
service, = Service.create([{
'service_date': self.start.date,

View File

@ -1,5 +1,5 @@
[tryton]
version=6.0.50
version=6.0.51
depends:
party
company

View File

@ -3,8 +3,8 @@
this repository contains the full copyright notices and license terms. -->
<tree editable="1">
<field name="room" widget="selection"/>
<field name="guest"/>
<field name="folio" expand="1"/>
<field name="guest"/>
<field name="time_service"/>
<field name="product"/>
<button name="load" string="Load"/>