[IMP] pms: out service and staff reservation improvementes

This commit is contained in:
Dario Lodeiros
2021-07-18 22:16:40 +02:00
parent d955fa009a
commit 185f6f0a39
5 changed files with 71 additions and 16 deletions

View File

@@ -53,7 +53,7 @@
<field name="reservation_sequence_id" ref="pms.seq_pms_reservation" />
</record>
<record id="demo_pms_property2" model="pms.property">
<field name="name">Agalia</field>
<field name="name">Algalia</field>
<field name="company_id" ref="base.main_company" />
<field name="default_pricelist_id" ref="product.list0" />
<field name="folio_sequence_id" ref="pms.seq_pms_folio" />

View File

@@ -625,7 +625,9 @@ class PmsFolio(models.Model):
)
def _compute_pricelist_id(self):
for folio in self:
if len(folio.reservation_ids.pricelist_id) == 1:
if folio.reservation_type in ("out", "staff"):
folio.pricelist_id = False
elif len(folio.reservation_ids.pricelist_id) == 1:
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
@@ -634,10 +636,12 @@ class PmsFolio(models.Model):
elif not folio.pricelist_id:
folio.pricelist_id = folio.pms_property_id.default_pricelist_id
@api.depends("agency_id")
@api.depends("agency_id", "reservation_type")
def _compute_partner_id(self):
for folio in self:
if folio.agency_id and folio.agency_id.invoice_to_agency:
if folio.reservation_type == "out":
folio.partner_id = False
elif folio.agency_id and folio.agency_id.invoice_to_agency:
folio.partner_id = folio.agency_id.id
elif not folio.partner_id:
folio.partner_id = False

View File

@@ -766,7 +766,9 @@ class PmsReservation(models.Model):
def _compute_partner_id(self):
for reservation in self:
if not reservation.partner_id:
if reservation.folio_id and reservation.folio_id.partner_id:
if reservation.reservation_type == "out":
reservation.partner_id = False
elif reservation.folio_id and reservation.folio_id.partner_id:
reservation.partner_id = reservation.folio_id.partner_id
elif reservation.agency_id and reservation.agency_id.invoice_to_agency:
reservation.partner_id = reservation.agency_id
@@ -843,6 +845,8 @@ class PmsReservation(models.Model):
@api.depends("partner_id", "agency_id")
def _compute_pricelist_id(self):
for reservation in self:
if reservation.reservation_type in ("out", "staff"):
reservation.pricelist_id = False
if reservation.agency_id and reservation.agency_id.apply_pricelist:
reservation.pricelist_id = (
reservation.agency_id.property_product_pricelist

View File

@@ -51,6 +51,9 @@ class BookingEngine(models.TransientModel):
string="Partner",
help="Partner who made the reservation",
comodel_name="res.partner",
compute="_compute_partner_id",
readonly=False,
store=True,
check_pms_properties=True,
)
folio_id = fields.Many2one(
@@ -69,6 +72,13 @@ class BookingEngine(models.TransientModel):
compute="_compute_availability_results",
check_pms_properties=True,
)
reservation_type = fields.Selection(
string="Type",
help="The type of the reservation. "
"Can be 'Normal', 'Staff' or 'Out of Service'",
default=lambda *a: "normal",
selection=[("normal", "Normal"), ("staff", "Staff"), ("out", "Out of Service")],
)
agency_id = fields.Many2one(
string="Agency",
help="Agency that made the reservation",
@@ -141,7 +151,7 @@ class BookingEngine(models.TransientModel):
elif not record.partner_id:
record.partner_id = False
@api.depends("partner_id")
@api.depends("partner_id", "agency_id")
def _compute_partner_name(self):
for record in self:
if record.partner_id:
@@ -164,7 +174,7 @@ class BookingEngine(models.TransientModel):
for record in self:
record.availability_results = False
if record.start_date and record.end_date and record.pricelist_id:
if record.start_date and record.end_date:
if record.end_date == record.start_date:
record.end_date = record.end_date + datetime.timedelta(days=1)
@@ -215,6 +225,7 @@ class BookingEngine(models.TransientModel):
if not record.folio_id:
folio = self.env["pms.folio"].create(
{
"reservation_type": record.reservation_type,
"pricelist_id": record.pricelist_id.id,
"partner_id": record.partner_id.id
if record.partner_id

View File

@@ -8,6 +8,7 @@
<div class="row">
<div class="col-5 ">
<group>
<field name="reservation_type" />
<field
name="start_date"
widget="daterange"
@@ -19,8 +20,15 @@
options="{'related_start_date': 'start_date'}"
/>
<field name="folio_id" invisible="1" />
<field name="agency_id" />
<field name="segmentation_ids" widget="many2many_tags" />
<field
name="agency_id"
attrs="{'invisible': [('reservation_type','!=','normal')]}"
/>
<field
name="segmentation_ids"
widget="many2many_tags"
attrs="{'invisible': [('reservation_type','!=','normal')]}"
/>
</group>
</div>
<div class="col-5">
@@ -28,22 +36,37 @@
<field
name="partner_id"
string="Partner"
required="1"
options="{'no_create': True,'no_open': True}"
attrs="{'invisible': [('reservation_type','=','out')]}"
/>
<field
name="partner_name"
string="Partner"
required="1"
attrs="{'invisible': [('reservation_type','=','out')]}"
/>
<field
name="partner_name"
string="Reason"
required="1"
attrs="{'invisible': [('reservation_type','!=','out')]}"
/>
<field
name="pms_property_id"
required="1"
attrs="{'invisible':[('folio_id','!=',0)]}"
attrs="{'readonly':[('folio_id','!=',0)]}"
/>
<field
default_focus="1"
name="pricelist_id"
string="Pricelist"
required="1"
options="{'no_create': True,'no_open': True}"
attrs="{'required': [('reservation_type','=','normal')], 'invisible': [('reservation_type','!=','normal')]}"
/>
<field
name="channel_type_id"
attrs="{'invisible': [('reservation_type','!=','normal')]}"
/>
<field name="channel_type_id" />
</group>
</div>
</div>
@@ -83,16 +106,21 @@
attrs="{'readonly':[('num_rooms_available','&lt;',1)]}"
force_save="1"
/>
<field name="board_service_room_id" />
<field
name="board_service_room_id"
attrs="{'column_invisible': [('parent.reservation_type','!=','normal')]}"
/>
<field
name="price_per_room"
readonly="1"
force_save="1"
attrs="{'column_invisible': [('parent.reservation_type','!=','normal')]}"
/>
<field
name="price_total"
readonly="1"
force_save="1"
attrs="{'column_invisible': [('parent.reservation_type','!=','normal')]}"
/>
</tree>
@@ -103,11 +131,19 @@
<div class="row float-right border mr-2 mb-5">
<div class="col-3 ">
<group>
<field name="discount" widget="percentage" />
<field
name="discount"
widget="percentage"
attrs="{'invisible': [('reservation_type','!=','normal')]}"
/>
</group>
<div class="col-3 px-0">
<group>
<field name="total_price_folio" widget="monetary" />
<field
name="total_price_folio"
widget="monetary"
attrs="{'invisible': [('reservation_type','!=','normal')]}"
/>
</group>
</div>
</div>