mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]pms: pricelist pms enabled configuration
This commit is contained in:
@@ -39,6 +39,7 @@ class PmsAvailabilityPlan(models.Model):
|
||||
comodel_name="product.pricelist",
|
||||
inverse_name="availability_plan_id",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
|
||||
rule_ids = fields.One2many(
|
||||
|
||||
@@ -20,6 +20,7 @@ class PmsCancelationRule(models.Model):
|
||||
comodel_name="product.pricelist",
|
||||
inverse_name="cancelation_rule_id",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
pms_property_ids = fields.Many2many(
|
||||
string="Properties",
|
||||
|
||||
@@ -872,7 +872,11 @@ class PmsFolio(models.Model):
|
||||
folio.pricelist_id = folio.reservation_ids.pricelist_id
|
||||
elif folio.agency_id and folio.agency_id.apply_pricelist:
|
||||
folio.pricelist_id = folio.agency_id.property_product_pricelist
|
||||
elif folio.partner_id and folio.partner_id.property_product_pricelist:
|
||||
elif (
|
||||
folio.partner_id
|
||||
and folio.partner_id.property_product_pricelist
|
||||
and folio.partner_id.property_product_pricelist.is_pms_available
|
||||
):
|
||||
folio.pricelist_id = folio.partner_id.property_product_pricelist
|
||||
elif not folio.pricelist_id:
|
||||
folio.pricelist_id = folio.pms_property_id.default_pricelist_id
|
||||
|
||||
@@ -57,6 +57,7 @@ class PmsProperty(models.Model):
|
||||
help="The default pricelist used in this property.",
|
||||
comodel_name="product.pricelist",
|
||||
required=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
default=lambda self: self.env.ref("product.list0").id,
|
||||
)
|
||||
default_arrival_hour = fields.Char(
|
||||
|
||||
@@ -209,6 +209,7 @@ class PmsReservation(models.Model):
|
||||
compute="_compute_pricelist_id",
|
||||
tracking=True,
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
user_id = fields.Many2one(
|
||||
string="Reception Manager",
|
||||
@@ -1017,6 +1018,7 @@ class PmsReservation(models.Model):
|
||||
elif (
|
||||
reservation.partner_id
|
||||
and reservation.partner_id.property_product_pricelist
|
||||
and reservation.partner_id.property_product_pricelist.is_pms_available
|
||||
and (
|
||||
not reservation.pricelist_id
|
||||
or not isinstance(reservation.id, models.NewId)
|
||||
|
||||
@@ -25,6 +25,7 @@ class PmsSaleChannel(models.Model):
|
||||
column1="pms_sale_channel_id",
|
||||
column2="product_pricelist_id",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
pms_property_ids = fields.Many2many(
|
||||
string="Properties",
|
||||
|
||||
@@ -65,6 +65,11 @@ class ProductPricelist(models.Model):
|
||||
help="Items for which the pricelist is made up",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
is_pms_available = fields.Boolean(
|
||||
string="Available in PMS",
|
||||
help="If the pricelist is available in the PMS",
|
||||
default=True,
|
||||
)
|
||||
|
||||
def _compute_price_rule_get_items(
|
||||
self, products_qty_partner, date, uom_id, prod_tmpl_ids, prod_ids, categ_ids
|
||||
|
||||
@@ -925,3 +925,21 @@ class ResPartner(models.Model):
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@api.constrains("is_agency", "property_product_pricelist")
|
||||
def _check_agency_pricelist(self):
|
||||
if any(
|
||||
record.is_agency and not record.property_product_pricelist.is_pms_available
|
||||
for record in self
|
||||
):
|
||||
raise models.ValidationError(
|
||||
_(
|
||||
"""
|
||||
Agency must have a PMS pricelist, please review the
|
||||
pricelists configuration (%s) to allow it for PMS,
|
||||
or the pricelist selected for the agencies: %s
|
||||
"""
|
||||
),
|
||||
",".join(self.mapped("property_product_pricelis.name")),
|
||||
"".join(self.mapped("name")),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user