mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Add fields in booking engine (#84)
* [IMP] Add fields in folio wizard * pre-commit * [IMP] Compute service line qty automatically * [IMP] many2many widget segmentation fiel bookin engine Co-authored-by: Darío Lodeiros <dario@commitsun.com>
This commit is contained in:
@@ -30,6 +30,9 @@ class FolioWizard(models.TransientModel):
|
||||
string="Property",
|
||||
default=lambda self: self._default_pms_property_id(),
|
||||
)
|
||||
segmentation_ids = fields.Many2many(
|
||||
"res.partner.category", string="Segmentation", ondelete="restrict"
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
"res.partner",
|
||||
)
|
||||
@@ -43,6 +46,21 @@ class FolioWizard(models.TransientModel):
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
agency_id = fields.Many2one(
|
||||
string="Agency",
|
||||
comodel_name="res.partner",
|
||||
ondelete="restrict",
|
||||
domain=[("is_agency", "=", True)],
|
||||
)
|
||||
channel_type_id = fields.Many2one(
|
||||
string="Direct Sale Channel",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="pms.sale.channel",
|
||||
domain=[("channel_type", "=", "direct")],
|
||||
compute="_compute_channel_type_id",
|
||||
ondelete="restrict",
|
||||
)
|
||||
total_price_folio = fields.Float(
|
||||
string="Total Price", compute="_compute_total_price_folio"
|
||||
)
|
||||
@@ -71,6 +89,12 @@ class FolioWizard(models.TransientModel):
|
||||
for record in self:
|
||||
record.pricelist_id = record.partner_id.property_product_pricelist.id
|
||||
|
||||
@api.depends("agency_id")
|
||||
def _compute_channel_type_id(self):
|
||||
for record in self:
|
||||
if record.agency_id:
|
||||
record.channel_type_id = record.agency_id.sale_channel_id.id
|
||||
|
||||
@api.depends("availability_results.price_total", "discount")
|
||||
def _compute_total_price_folio(self):
|
||||
for record in self:
|
||||
@@ -144,6 +168,9 @@ class FolioWizard(models.TransientModel):
|
||||
"pricelist_id": record.pricelist_id.id,
|
||||
"partner_id": record.partner_id.id,
|
||||
"pms_property_id": record.pms_property_id.id,
|
||||
"agency_id": record.agency_id.id,
|
||||
"channel_type_id": record.channel_type_id.id,
|
||||
"segmentation_ids": [(6, 0, record.segmentation_ids.ids)],
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -159,6 +186,7 @@ class FolioWizard(models.TransientModel):
|
||||
"partner_id": record.partner_id.id,
|
||||
"pricelist_id": record.pricelist_id.id,
|
||||
"pms_property_id": folio.pms_property_id.id,
|
||||
"board_service_room_id": line.board_service_room_id.id,
|
||||
}
|
||||
)
|
||||
res.reservation_line_ids.discount = record.discount * 100
|
||||
|
||||
@@ -19,11 +19,18 @@
|
||||
options="{'related_start_date': 'start_date'}"
|
||||
/>
|
||||
<field name="folio_id" invisible="1" />
|
||||
<field name="agency_id" />
|
||||
<field name="segmentation_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<group>
|
||||
<field name="partner_id" string="Partner" required="1" />
|
||||
<field
|
||||
name="partner_id"
|
||||
string="Partner"
|
||||
required="1"
|
||||
options="{'no_create': True,'no_open': True}"
|
||||
/>
|
||||
<field
|
||||
name="pms_property_id"
|
||||
required="1"
|
||||
@@ -35,7 +42,9 @@
|
||||
string="Pricelist"
|
||||
required="1"
|
||||
domain="['|', ('pms_property_ids', '=', False), ('pms_property_ids', 'in', pms_property_id)]"
|
||||
options="{'no_create': True,'no_open': True}"
|
||||
/>
|
||||
<field name="channel_type_id" />
|
||||
</group>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,6 +84,7 @@
|
||||
attrs="{'readonly':[('num_rooms_available','<',1)]}"
|
||||
force_save="1"
|
||||
/>
|
||||
<field name="board_service_room_id" />
|
||||
<field
|
||||
name="price_per_room"
|
||||
readonly="1"
|
||||
|
||||
@@ -58,8 +58,15 @@ class AvailabilityWizard(models.TransientModel):
|
||||
related="folio_wizard_id.pms_property_id",
|
||||
string="Property",
|
||||
)
|
||||
board_service_room_id = fields.Many2one(
|
||||
string="Board Service",
|
||||
help="Board Service included in the room",
|
||||
comodel_name="pms.board.service.room.type",
|
||||
domain="[('pms_room_type_id','=',room_type_id)]",
|
||||
tracking=True,
|
||||
)
|
||||
|
||||
@api.depends("num_rooms_selected", "checkin", "checkout")
|
||||
@api.depends("num_rooms_selected", "checkin", "checkout", "board_service_room_id")
|
||||
def _compute_price_total(self):
|
||||
for record in self:
|
||||
record.price_total = 0
|
||||
@@ -88,6 +95,12 @@ class AvailabilityWizard(models.TransientModel):
|
||||
)
|
||||
room_type_total_price_per_room += product.price
|
||||
|
||||
if record.board_service_room_id:
|
||||
nights = (record.checkout - record.checkin).days
|
||||
room_type_total_price_per_room += (
|
||||
record.board_service_room_id.amount * nights
|
||||
)
|
||||
|
||||
# udpate the price per room
|
||||
record.price_per_room = room_type_total_price_per_room
|
||||
|
||||
|
||||
Reference in New Issue
Block a user