mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Security Rules
This commit is contained in:
@@ -12,18 +12,20 @@ class HotelBoardServiceLine(models.Model):
|
||||
def _get_default_price(self):
|
||||
if self.product_id:
|
||||
return self.product_id.list_price
|
||||
|
||||
|
||||
hotel_board_service_id = fields.Many2one(
|
||||
'hotel.board.service', 'Board Service', ondelete='cascade', required=True)
|
||||
'hotel.board.service',
|
||||
'Board Service',
|
||||
ondelete='cascade',
|
||||
required=True)
|
||||
product_id = fields.Many2one(
|
||||
'product.product', 'Product', required=True)
|
||||
amount = fields.Float('Amount',
|
||||
digits=dp.get_precision('Product Price'), default=_get_default_price)
|
||||
amount = fields.Float(
|
||||
'Amount',
|
||||
digits=dp.get_precision('Product Price'),
|
||||
default=_get_default_price)
|
||||
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
if self.product_id:
|
||||
self.update({'amount': self.product_id.list_price})
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -169,11 +169,17 @@ class HotelService(models.Model):
|
||||
if self.compute_lines_out_vals(vals):
|
||||
reservation = self.env['hotel.reservation'].browse(vals['ser_room_line'])
|
||||
product = self.env['product.product'].browse(vals['product_id'])
|
||||
checkin_dt = fields.Date.from_string(reservation.real_checkin)
|
||||
checkout_dt = fields.Date.from_string(reservation.real_checkout)
|
||||
if reservation.splitted:
|
||||
checkin = reservation.real_checkin
|
||||
checkout = reservation.real_checkout
|
||||
else:
|
||||
checkin = reservation.checkin
|
||||
checkout = reservation.checkout
|
||||
checkin_dt = fields.Date.from_string(checkin)
|
||||
checkout_dt = fields.Date.from_string(checkout)
|
||||
nights = abs((checkout_dt - checkin_dt).days)
|
||||
vals.update(self.prepare_service_lines(
|
||||
dfrom=reservation.real_checkin,
|
||||
dfrom=checkin,
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
@@ -190,18 +196,24 @@ class HotelService(models.Model):
|
||||
product = self.env['product.product'].browse(vals.get('product_id'))
|
||||
if not product.per_day:
|
||||
vals.update({
|
||||
'service_line_ids' : [(5, 0, 0)]
|
||||
'service_line_ids': [(5, 0, 0)]
|
||||
})
|
||||
else:
|
||||
for record in self:
|
||||
reservations = self.env['hotel.reservation']
|
||||
reservation = reservations.browse(vals['ser_room_line']) \
|
||||
if 'ser_room_line' in vals else record.ser_room_line
|
||||
checkin_dt = fields.Date.from_string(reservation.real_checkin)
|
||||
checkout_dt = fields.Date.from_string(reservation.real_checkout)
|
||||
if reservation.splitted:
|
||||
checkin = reservation.real_checkin
|
||||
checkout = reservation.real_checkout
|
||||
else:
|
||||
checkin = reservation.checkin
|
||||
checkout = reservation.checkout
|
||||
checkin_dt = fields.Date.from_string(checkin)
|
||||
checkout_dt = fields.Date.from_string(checkout)
|
||||
nights = abs((checkout_dt - checkin_dt).days)
|
||||
record.update(record.prepare_service_lines(
|
||||
dfrom=reservation.real_checkin,
|
||||
dfrom=checkin,
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
@@ -277,11 +289,17 @@ class HotelService(models.Model):
|
||||
if record.per_day and record.ser_room_line:
|
||||
product = record.product_id
|
||||
reservation = record.ser_room_line
|
||||
checkin_dt = fields.Date.from_string(reservation.real_checkin)
|
||||
checkout_dt = fields.Date.from_string(reservation.real_checkout)
|
||||
if reservation.splitted:
|
||||
checkin = reservation.real_checkin
|
||||
checkout = reservation.real_checkout
|
||||
else:
|
||||
checkin = reservation.checkin
|
||||
checkout = reservation.checkout
|
||||
checkin_dt = fields.Date.from_string(checkin)
|
||||
checkout_dt = fields.Date.from_string(checkout)
|
||||
nights = abs((checkout_dt - checkin_dt).days)
|
||||
vals.update(record.prepare_service_lines(
|
||||
dfrom=reservation.real_checkin,
|
||||
dfrom=checkin,
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
|
||||
Reference in New Issue
Block a user