mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms: min price room type control
This commit is contained in:
@@ -90,6 +90,11 @@ class PmsRoomType(models.Model):
|
|||||||
related="class_id.overnight",
|
related="class_id.overnight",
|
||||||
store=True,
|
store=True,
|
||||||
)
|
)
|
||||||
|
min_price = fields.Float(
|
||||||
|
string="Min. Price",
|
||||||
|
help="Minimum price for a room type",
|
||||||
|
default=5.0,
|
||||||
|
)
|
||||||
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
result = []
|
result = []
|
||||||
|
|||||||
@@ -112,3 +112,36 @@ class ProductPricelistItem(models.Model):
|
|||||||
if domain
|
if domain
|
||||||
else False
|
else False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
# Check that the price in product room types are not
|
||||||
|
# minor that min price in room type defined
|
||||||
|
# REVIEW: By the momment only check fixed prices
|
||||||
|
if "fixed_price" in vals:
|
||||||
|
if any(
|
||||||
|
[
|
||||||
|
item.product_id.room_type_id
|
||||||
|
and item.product_id.room_type_id.min_price
|
||||||
|
and vals["fixed_price"] < item.product_id.room_type_id.min_price
|
||||||
|
for item in self
|
||||||
|
]
|
||||||
|
):
|
||||||
|
raise ValueError(
|
||||||
|
"""The price in product room types can't be minor
|
||||||
|
that min price in room type defined"""
|
||||||
|
)
|
||||||
|
return super().write(vals)
|
||||||
|
|
||||||
|
def create(self, vals):
|
||||||
|
# Check that the price in product room types are not
|
||||||
|
# minor that min price in room type defined
|
||||||
|
# REVIEW: By the momment only check fixed prices
|
||||||
|
if "fixed_price" in vals:
|
||||||
|
product_id = self.env["product.product"].browse(vals["product_id"])
|
||||||
|
if product_id.room_type_id and product_id.room_type_id.min_price:
|
||||||
|
if vals["fixed_price"] < product_id.room_type_id.min_price:
|
||||||
|
raise ValueError(
|
||||||
|
"""The price in product room types can't be minor
|
||||||
|
that min price in room type defined"""
|
||||||
|
)
|
||||||
|
return super().create(vals)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<field name="total_rooms_count" />
|
<field name="total_rooms_count" />
|
||||||
<field name="default_max_avail" />
|
<field name="default_max_avail" />
|
||||||
<field name="default_quota" />
|
<field name="default_quota" />
|
||||||
|
<field name="min_price" />
|
||||||
</group>
|
</group>
|
||||||
<group name="accounting_group">
|
<group name="accounting_group">
|
||||||
<field
|
<field
|
||||||
|
|||||||
Reference in New Issue
Block a user