mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] create services from reservation
This commit is contained in:
@@ -327,6 +327,9 @@ class HotelReservation(models.Model):
|
|||||||
vals.update({'folio_id': folio.id,
|
vals.update({'folio_id': folio.id,
|
||||||
'reservation_type': vals.get('reservation_type'),
|
'reservation_type': vals.get('reservation_type'),
|
||||||
'channel_type': vals.get('channel_type')})
|
'channel_type': vals.get('channel_type')})
|
||||||
|
if 'service_ids' in vals:
|
||||||
|
for service in vals['service_ids']:
|
||||||
|
service[2]['folio_id'] = folio.id
|
||||||
vals.update({
|
vals.update({
|
||||||
'last_updated_res': fields.Datetime.now(),
|
'last_updated_res': fields.Datetime.now(),
|
||||||
})
|
})
|
||||||
@@ -440,7 +443,7 @@ class HotelReservation(models.Model):
|
|||||||
""" Deduce missing required fields from the onchange """
|
""" Deduce missing required fields from the onchange """
|
||||||
res = {}
|
res = {}
|
||||||
onchange_fields = ['room_id', 'reservation_type',
|
onchange_fields = ['room_id', 'reservation_type',
|
||||||
'currency_id', 'name', 'board_service_room_id']
|
'currency_id', 'name', 'board_service_room_id','service_ids']
|
||||||
if values.get('room_type_id'):
|
if values.get('room_type_id'):
|
||||||
line = self.new(values)
|
line = self.new(values)
|
||||||
if any(f not in values for f in onchange_fields):
|
if any(f not in values for f in onchange_fields):
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ class HotelService(models.Model):
|
|||||||
return self.env.context.get('default_ser_room_line')
|
return self.env.context.get('default_ser_room_line')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_folio_id(self):
|
||||||
|
import wdb; wdb.set_trace()
|
||||||
|
if 'folio_id' in self._context:
|
||||||
|
return self._context['folio_id']
|
||||||
|
return False
|
||||||
|
|
||||||
@api.depends('qty_invoiced', 'product_qty', 'folio_id.state')
|
@api.depends('qty_invoiced', 'product_qty', 'folio_id.state')
|
||||||
def _get_to_invoice_qty(self):
|
def _get_to_invoice_qty(self):
|
||||||
"""
|
"""
|
||||||
@@ -114,7 +121,9 @@ class HotelService(models.Model):
|
|||||||
name = fields.Char('Service description', required=True)
|
name = fields.Char('Service description', required=True)
|
||||||
sequence = fields.Integer(string='Sequence', default=10)
|
sequence = fields.Integer(string='Sequence', default=10)
|
||||||
product_id = fields.Many2one('product.product', 'Service', required=True)
|
product_id = fields.Many2one('product.product', 'Service', required=True)
|
||||||
folio_id = fields.Many2one('hotel.folio', 'Folio', ondelete='cascade')
|
folio_id = fields.Many2one('hotel.folio', 'Folio',
|
||||||
|
ondelete='cascade',
|
||||||
|
default=_default_folio_id)
|
||||||
ser_room_line = fields.Many2one('hotel.reservation', 'Room',
|
ser_room_line = fields.Many2one('hotel.reservation', 'Room',
|
||||||
default=_default_ser_room_line)
|
default=_default_ser_room_line)
|
||||||
per_day = fields.Boolean(related='product_id.per_day')
|
per_day = fields.Boolean(related='product_id.per_day')
|
||||||
@@ -236,7 +245,7 @@ class HotelService(models.Model):
|
|||||||
def _compute_tax_ids(self):
|
def _compute_tax_ids(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
# If company_id is set, always filter taxes by the company
|
# If company_id is set, always filter taxes by the company
|
||||||
folio = record.folio_id or self.env.context.get('default_folio_id')
|
folio = record.folio_id or self.env['hotel.folio'].browse(self.env.context.get('default_folio_id'))
|
||||||
reservation = record.ser_room_line or self.env.context.get('ser_room_line')
|
reservation = record.ser_room_line or self.env.context.get('ser_room_line')
|
||||||
origin = folio if folio else reservation
|
origin = folio if folio else reservation
|
||||||
record.tax_ids = record.product_id.taxes_id.filtered(lambda r: not record.company_id or r.company_id == origin.company_id)
|
record.tax_ids = record.product_id.taxes_id.filtered(lambda r: not record.company_id or r.company_id == origin.company_id)
|
||||||
@@ -374,7 +383,7 @@ class HotelService(models.Model):
|
|||||||
Compute the amounts of the service line.
|
Compute the amounts of the service line.
|
||||||
"""
|
"""
|
||||||
for record in self:
|
for record in self:
|
||||||
folio = record.folio_id or self.env.context.get('default_folio_id')
|
folio = record.folio_id or self.env['hotel.folio'].browse(self.env.context.get('default_folio_id'))
|
||||||
reservation = record.ser_room_line or self.env.context.get('ser_room_line')
|
reservation = record.ser_room_line or self.env.context.get('ser_room_line')
|
||||||
currency = folio.currency_id if folio else reservation.currency_id
|
currency = folio.currency_id if folio else reservation.currency_id
|
||||||
product = record.product_id
|
product = record.product_id
|
||||||
|
|||||||
Reference in New Issue
Block a user