[ADD] Wizard reservations with Board Services

This commit is contained in:
Dario Lodeiros
2019-03-16 19:18:33 +01:00
parent 682cb584f0
commit eebd1e10dc
4 changed files with 110 additions and 71 deletions

View File

@@ -342,7 +342,7 @@ class HotelReservation(models.Model):
folio = self.env["hotel.folio"].browse(vals['folio_id'])
vals.update({'channel_type': folio.channel_type})
elif 'partner_id' in vals:
folio_vals = {'partner_id':int(vals.get('partner_id')),
folio_vals = {'partner_id': int(vals.get('partner_id')),
'channel_type': vals.get('channel_type')}
# Create the folio in case of need (To allow to create reservations direct)
folio = self.env["hotel.folio"].create(folio_vals)
@@ -441,8 +441,8 @@ class HotelReservation(models.Model):
if 'service_ids' in vals:
for service in vals['service_ids']:
if 'is_board_service' in service[2] and \
service[2]['is_board_service'] == True:
return False
service[2]['is_board_service'] is True:
return False
return True
return False
@@ -728,6 +728,7 @@ class HotelReservation(models.Model):
'product_id': product.id,
'is_board_service': True,
'folio_id': self.folio_id.id,
'ser_room_line': self.id,
}
line = self.env['hotel.service'].new(res)
res.update(self.env['hotel.service']._prepare_add_missing_fields(res))
@@ -738,10 +739,10 @@ class HotelReservation(models.Model):
persons=self.adults,
old_line_days=False))
board_services.append((0, False, res))
other_services = self.service_ids.filtered(lambda r: r.is_board_service == False)
other_services = self.service_ids.filtered(lambda r: not r.is_board_service)
self.update({'service_ids': board_services})
self.service_ids |= other_services
for service in self.service_ids.filtered(lambda r: r.is_board_service == True):
for service in self.service_ids.filtered(lambda r: r.is_board_service):
service._compute_tax_ids()
service.price_unit = service._compute_price_unit()

View File

@@ -209,7 +209,7 @@ class HotelService(models.Model):
def _prepare_add_missing_fields(self, values):
""" Deduce missing required fields from the onchange """
res = {}
onchange_fields = ['price_unit','tax_ids','name']
onchange_fields = ['price_unit', 'tax_ids', 'name']
if values.get('product_id'):
line = self.new(values)
if any(f not in values for f in onchange_fields):
@@ -317,7 +317,7 @@ class HotelService(models.Model):
self.ensure_one()
folio = self.folio_id or self.env.context.get('default_folio_id')
reservation = self.ser_room_line or self.env.context.get('ser_room_line')
origin = folio if folio else reservation
origin = reservation if reservation else folio
if origin:
partner = origin.partner_id
pricelist = origin.pricelist_id