mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] consumed_on in service by day
This commit is contained in:
@@ -446,7 +446,8 @@ class HotelReservation(models.Model):
|
||||
days=days_diff,
|
||||
per_person=service.product_id.per_person,
|
||||
persons=service.ser_room_line.adults,
|
||||
old_line_days=service.service_line_ids
|
||||
old_line_days=service.service_line_ids,
|
||||
consumed_on=service.product_id.consumed_on,
|
||||
))
|
||||
if ('checkin' in vals and record.checkin != vals['checkin']) or\
|
||||
('checkout' in vals and record.checkout != vals['checkout']) or\
|
||||
@@ -787,7 +788,8 @@ class HotelReservation(models.Model):
|
||||
days=self.nights,
|
||||
per_person=product.per_person,
|
||||
persons=self.adults,
|
||||
old_line_days=False))
|
||||
old_line_days=False,
|
||||
consumed_on=product.consumed_on,))
|
||||
board_services.append((0, False, res))
|
||||
other_services = self.service_ids.filtered(lambda r: not r.is_board_service)
|
||||
self.update({'service_ids': board_services})
|
||||
|
||||
@@ -187,6 +187,7 @@ class HotelService(models.Model):
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
old_day_lines=False,
|
||||
consumed_on=product.consumed_on,
|
||||
))
|
||||
record = super(HotelService, self).create(vals)
|
||||
return record
|
||||
@@ -220,7 +221,8 @@ class HotelService(models.Model):
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
old_line_days=self.service_line_ids
|
||||
old_line_days=self.service_line_ids,
|
||||
consumed_on=product.consumed_on,
|
||||
))
|
||||
res = super(HotelService, self).write(vals)
|
||||
return res
|
||||
@@ -306,7 +308,9 @@ class HotelService(models.Model):
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=reservation.adults,
|
||||
old_line_days=record.service_line_ids))
|
||||
old_line_days=record.service_line_ids,
|
||||
consumed_on=product.consumed_on,
|
||||
))
|
||||
if record.product_id.daily_limit > 0:
|
||||
for i in range(0, nights):
|
||||
idate = (fields.Date.from_string(checkin) + timedelta(days=i)).strftime(
|
||||
@@ -385,11 +389,14 @@ class HotelService(models.Model):
|
||||
"""
|
||||
cmds = [(5, 0, 0)]
|
||||
old_line_days = kwargs.get('old_line_days')
|
||||
consumed_on = kwargs.get('consumed_on') if kwargs.get('consumed_on') else 'before'
|
||||
total_qty = 0
|
||||
day_qty = 1
|
||||
if kwargs.get('per_person'): #WARNING: Change adults in reservation NOT update qty service!!
|
||||
day_qty = kwargs.get('persons')
|
||||
for i in range(0, kwargs.get('days')):
|
||||
if consumed_on == 'after':
|
||||
i += 1
|
||||
idate = (fields.Date.from_string(kwargs.get('dfrom')) + timedelta(days=i)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
if not old_line_days or idate not in old_line_days.mapped('date'):
|
||||
|
||||
@@ -9,7 +9,10 @@ class ProductTemplate(models.Model):
|
||||
|
||||
per_day = fields.Boolean('Unit increment per day')
|
||||
per_person = fields.Boolean('Unit increment per person')
|
||||
consumed_on = fields.Selection([
|
||||
('before', 'Before night'),
|
||||
('after', 'After night')], 'Consumed', default='before')
|
||||
daily_limit = fields.Integer('Daily limit')
|
||||
is_extra_bed = fields.Boolean('Is extra bed', default=False)
|
||||
show_in_calendar = fields.Boolean('Show in Calendar', default=False,
|
||||
help='Specifies if the product is shown in the calendar information.')
|
||||
help='Specifies if the product is shown in the calendar information.')
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<group>
|
||||
<field name="per_day" />
|
||||
<field name="per_person" />
|
||||
<field name="consumed_on" widget="radio"
|
||||
attrs="{'invisible': [('per_day','!=',True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
@@ -542,7 +542,8 @@ class ReservationWizard(models.TransientModel):
|
||||
days=nights,
|
||||
per_person=product.per_person,
|
||||
persons=line.adults,
|
||||
old_line_days=False))
|
||||
old_line_days=False,
|
||||
consumed_on=product.consumed_on,))
|
||||
service_line.update(vals)
|
||||
price_product = service_line.price_unit * (1 - (line.discount or 0.0) * 0.01)
|
||||
pricelist = line.folio_wizard_id.pricelist_id
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
<xpath expr="//field[@name='partner_id']" position="attributes">
|
||||
<attribute name="options">{"no_create": True}</attribute>
|
||||
<attribute name="required">False</attribute>
|
||||
<attribute name="string">'Search'</attribute>
|
||||
<attribute name="string">Search</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_on_board']" position="before">
|
||||
<button type="action" class="oe_stat_button"
|
||||
|
||||
Reference in New Issue
Block a user