mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Channels online and Pricelist allowed by channels (#42)
This commit is contained in:
@@ -152,6 +152,9 @@ class PmsFolio(models.Model):
|
||||
)
|
||||
channel_type_id = fields.Many2one(
|
||||
"pms.sale.channel",
|
||||
compute="_compute_channel_type_id",
|
||||
readonly=False,
|
||||
store=True,
|
||||
string="Direct Sale Channel",
|
||||
ondelete="restrict",
|
||||
domain=[("channel_type", "=", "direct")],
|
||||
@@ -503,6 +506,12 @@ class PmsFolio(models.Model):
|
||||
else:
|
||||
folio.commission = 0
|
||||
|
||||
@api.depends("agency_id")
|
||||
def _compute_channel_type_id(self):
|
||||
for folio in self:
|
||||
if folio.agency_id:
|
||||
folio.channel_type_id = folio.agency_id.sale_channel_id.id
|
||||
|
||||
@api.depends("sale_line_ids.invoice_lines")
|
||||
def _compute_get_invoiced(self):
|
||||
# The invoice_ids are obtained thanks to the invoice lines of the SO
|
||||
@@ -639,7 +648,7 @@ class PmsFolio(models.Model):
|
||||
@api.depends("pending_checkin_data")
|
||||
def _compute_ratio_checkin_data(self):
|
||||
self.ratio_checkin_data = 0
|
||||
for folio in self:
|
||||
for folio in self.filtered("reservation_ids"):
|
||||
folio.ratio_checkin_data = (
|
||||
(
|
||||
sum(folio.reservation_ids.mapped("adults"))
|
||||
@@ -1191,8 +1200,14 @@ class PmsFolio(models.Model):
|
||||
@api.constrains("agency_id", "channel_type_id")
|
||||
def _check_only_one_channel(self):
|
||||
for record in self:
|
||||
if record.agency_id and record.channel_type_id:
|
||||
raise models.ValidationError(_("There must be only one sale channel"))
|
||||
if (
|
||||
record.agency_id
|
||||
and record.channel_type_id.channel_type
|
||||
!= record.agency_id.sale_channel_id.channel_type
|
||||
):
|
||||
raise models.ValidationError(
|
||||
_("The Sale Channel does not correspond to the agency's")
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _prepare_down_payment_section_line(self, **optional_values):
|
||||
|
||||
@@ -143,7 +143,6 @@ class PmsReservation(models.Model):
|
||||
channel_type_id = fields.Many2one(
|
||||
related="folio_id.channel_type_id",
|
||||
readonly=False,
|
||||
store=True,
|
||||
)
|
||||
partner_invoice_id = fields.Many2one(
|
||||
"res.partner",
|
||||
@@ -643,6 +642,8 @@ class PmsReservation(models.Model):
|
||||
@api.depends("partner_id")
|
||||
def _compute_pricelist_id(self):
|
||||
for reservation in self:
|
||||
# TODO: Review logic pricelist by partner
|
||||
# and by allowed channel pricelist_ids
|
||||
if reservation.folio_id:
|
||||
pricelist_id = reservation.folio_id.pricelist_id.id
|
||||
else:
|
||||
|
||||
@@ -10,3 +10,5 @@ class PmsSaleChannel(models.Model):
|
||||
channel_type = fields.Selection(
|
||||
[("direct", "Direct"), ("indirect", "Indirect")], string="Sale Channel Type"
|
||||
)
|
||||
on_line = fields.Boolean("On Line")
|
||||
product_pricelist_ids = fields.Many2many("product.pricelist", string="Pricelists")
|
||||
|
||||
@@ -25,6 +25,9 @@ class ProductPricelist(models.Model):
|
||||
pricelist_type = fields.Selection(
|
||||
[("daily", "Daily Plan")], string="Pricelist Type", default="daily"
|
||||
)
|
||||
pms_sale_channel_ids = fields.Many2many(
|
||||
"pms.sale.channel", string="Available Channels"
|
||||
)
|
||||
|
||||
availability_plan_id = fields.Many2one(
|
||||
comodel_name="pms.room.type.availability.plan",
|
||||
|
||||
@@ -168,16 +168,11 @@
|
||||
name="reservation_type"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"
|
||||
/>
|
||||
<!--<field
|
||||
name="channel_type"
|
||||
attrs="{'required':[('reservation_type','=','normal')]}"
|
||||
/>
|
||||
<field
|
||||
name="agency_id"
|
||||
options="{'no_create': True,'no_open': True}"
|
||||
/>-->
|
||||
<field name="agency_id" />
|
||||
<field name="channel_type_id" />
|
||||
<field
|
||||
name="channel_type_id"
|
||||
attrs="{'readonly':[('agency_id','!=', False)]}"
|
||||
/>
|
||||
<field name="internal_comment" />
|
||||
</group>
|
||||
<group
|
||||
|
||||
@@ -319,7 +319,10 @@
|
||||
placeholder="Reservation Notes"
|
||||
/>
|
||||
<field name="agency_id" />
|
||||
<field name="channel_type_id" />
|
||||
<field
|
||||
name="channel_type_id"
|
||||
attrs="{'readonly':[('agency_id','!=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
<group
|
||||
colspan="2"
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<group>
|
||||
<field name="name" colspan="1" />
|
||||
<field name="channel_type" />
|
||||
<field name="on_line" />
|
||||
<field name="product_pricelist_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
@@ -21,6 +23,8 @@
|
||||
<tree string=" Sale Channel">
|
||||
<field name="name" />
|
||||
<field name="channel_type" />
|
||||
<field name="on_line" />
|
||||
<field name="product_pricelist_ids" widget="many2many_tags" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<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']"
|
||||
|
||||
Reference in New Issue
Block a user