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")),
|
||||
)
|
||||
|
||||
@@ -4,27 +4,51 @@
|
||||
<field name="model">product.pricelist</field>
|
||||
<field name="inherit_id" ref="product.product_pricelist_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='country_group_ids']" position="before">
|
||||
<xpath expr="//field[@name='company_id']" position="after">
|
||||
<field name="is_pms_available" />
|
||||
<field
|
||||
name="pms_property_ids"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='country_group_ids']" position="before">
|
||||
<field
|
||||
name="pricelist_type"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="cancelation_rule_id"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="availability_plan_id"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="pms_sale_channel_ids"
|
||||
widget="many2many_tags"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field name="pricelist_type" />
|
||||
<field name="cancelation_rule_id" />
|
||||
<field name="availability_plan_id" />
|
||||
<field name="pms_sale_channel_ids" widget="many2many_tags" />
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='item_ids']/tree/field[@name='base']"
|
||||
position="after"
|
||||
>
|
||||
<field name="date_start_consumption" />
|
||||
<field name="date_end_consumption" />
|
||||
<field
|
||||
name="date_start_consumption"
|
||||
attrs="{'column_invisible': [('parent.is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="date_end_consumption"
|
||||
attrs="{'column_invisible': [('parent.is_pms_available', '=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="pms_property_ids"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'column_invisible': [('parent.is_pms_available', '=', False)]}"
|
||||
/>
|
||||
</xpath>
|
||||
|
||||
@@ -36,6 +60,7 @@
|
||||
<field
|
||||
name="board_service_room_type_id"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
attrs="{'invisible': [('parent.is_pms_available', '=', False)]}"
|
||||
/>
|
||||
</xpath>
|
||||
|
||||
@@ -48,6 +73,7 @@
|
||||
type="object"
|
||||
class="oe_stat_button mr-5"
|
||||
icon="fa-magic"
|
||||
attrs="{'invisible': [('is_pms_available', '=', False)]}"
|
||||
>
|
||||
<label
|
||||
for="open_massive_changes_wizard"
|
||||
|
||||
@@ -33,6 +33,7 @@ class BookingDuplicate(models.TransientModel):
|
||||
comodel_name="product.pricelist",
|
||||
compute="_compute_pricelist_id",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
pms_property_id = fields.Many2one(
|
||||
related="reference_folio_id.pms_property_id",
|
||||
@@ -454,6 +455,7 @@ class PmsReservationDuplicate(models.TransientModel):
|
||||
help="Pricelist used for this reservation",
|
||||
comodel_name="product.pricelist",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
price_total = fields.Float(
|
||||
string="Total price",
|
||||
|
||||
@@ -26,6 +26,7 @@ class BookingEngine(models.TransientModel):
|
||||
comodel_name="product.pricelist",
|
||||
compute="_compute_pricelist_id",
|
||||
check_pms_properties=True,
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
pms_property_id = fields.Many2one(
|
||||
string="Property",
|
||||
@@ -132,7 +133,11 @@ class BookingEngine(models.TransientModel):
|
||||
@api.depends("partner_id")
|
||||
def _compute_pricelist_id(self):
|
||||
for record in self:
|
||||
record.pricelist_id = record.partner_id.property_product_pricelist.id
|
||||
record.pricelist_id = (
|
||||
record.partner_id.property_product_pricelist.id
|
||||
if record.partner_id.property_product_pricelist.is_pms_available
|
||||
else self.pms_property_id.default_pricelist_id.id
|
||||
)
|
||||
|
||||
@api.depends("agency_id")
|
||||
def _compute_channel_type_id(self):
|
||||
|
||||
@@ -140,6 +140,7 @@ class WizardFolioChanges(models.TransientModel):
|
||||
new_pricelist_id = fields.Many2one(
|
||||
string="Pricelist",
|
||||
comodel_name="product.pricelist",
|
||||
domain="[('is_pms_available', '=', True)]",
|
||||
)
|
||||
|
||||
apply_board_service = fields.Boolean(
|
||||
|
||||
@@ -280,6 +280,7 @@ class AvailabilityWizard(models.TransientModel):
|
||||
for record in self:
|
||||
record.allowed_pricelist_ids = self.env["product.pricelist"].search(
|
||||
[
|
||||
("is_pms_available", "=", True),
|
||||
("pricelist_type", "=", "daily"),
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user