mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: add compute total reservation line price by date
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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')]}"
|
||||
|
||||
Reference in New Issue
Block a user