[IMP]pms: add compute total reservation line price by date

This commit is contained in:
Darío Lodeiros
2022-10-23 17:24:26 +02:00
parent d62a11a269
commit 82d0059b10
2 changed files with 16 additions and 1 deletions

View File

@@ -88,13 +88,18 @@ class PmsReservationLine(models.Model):
compute="_compute_avail_id",
check_pms_properties=True,
)
discount = fields.Float(
string="Discount (%)",
help="",
default=0.0,
digits=("Discount"),
)
price_day_total = fields.Float(
string="Final price",
help="Get the price with discount applied",
store=True,
compute="_compute_price_day_total",
)
occupies_availability = fields.Boolean(
string="Occupies",
help="This record is taken into account to calculate availability",
@@ -473,6 +478,15 @@ class PmsReservationLine(models.Model):
else:
record.avail_id = False
@api.depends("price", "discount", "cancel_discount")
def _compute_price_day_total(self):
for line in self:
first_discount = line.price * ((line.discount or 0.0) * 0.01)
price = line.price - first_discount
cancel_discount = price * ((line.cancel_discount or 0.0) * 0.01)
discount = first_discount + cancel_discount
line.price_day_total = line.price - discount
@api.depends("reservation_id.overbooking")
def _compute_overbooking(self):
for record in self:

View File

@@ -498,6 +498,7 @@
<field name="date" readonly="1" force_save="1" />
<field name="price" />
<field name="discount" />
<field name="price_day_total" />
<field
name="cancel_discount"
attrs="{'column_invisible': [('parent.state','!=','cancel')]}"