[IMP]pms: replace reservation sequence by folio + compute sequence

This commit is contained in:
Darío Lodeiros
2022-04-07 19:10:29 +02:00
parent 19029b4f4d
commit 2e5f4f4447
7 changed files with 15 additions and 47 deletions

View File

@@ -18,7 +18,6 @@
<field name="website">https://www.commitsun.com</field>
<field name="folio_sequence_id" ref="pms.seq_pms_folio" />
<field name="checkin_sequence_id" ref="pms.seq_pms_checkin" />
<field name="reservation_sequence_id" ref="pms.seq_pms_reservation" />
</record>
<!-- default partner simplified invoices -->
<record id="various_pms_partner" model="res.partner">

View File

@@ -8,13 +8,6 @@
<field name="padding">5</field>
</record>
<record model="ir.sequence" id="seq_pms_reservation">
<field name="name">PMS Reservation</field>
<field name="code">pms.reservation</field>
<field name="prefix">R%(y)s</field>
<field name="padding">6</field>
</record>
<record model="ir.sequence" id="seq_pms_checkin">
<field name="name">PMS Checkin</field>
<field name="code">pms.checkin.partner</field>

View File

@@ -28,14 +28,6 @@
<field name="padding">4</field>
<field name="company_id" ref="pms_company1" />
</record>
<record model="ir.sequence" id="seq_pms_reservation2">
<field name="name">PMS Reservation 2</field>
<field name="code">pms.reservation</field>
<field name="prefix">R/%(y)s</field>
<field name="suffix">%(sec)s</field>
<field name="padding">4</field>
<field name="company_id" ref="pms_company1" />
</record>
<record model="ir.sequence" id="seq_pms_checkin2">
<field name="name">PMS Checkin 2</field>
<field name="code">pms.checkin.partner</field>
@@ -51,7 +43,6 @@
<field name="default_pricelist_id" ref="product.list0" />
<field name="folio_sequence_id" ref="pms.seq_pms_folio" />
<field name="checkin_sequence_id" ref="pms.seq_pms_checkin" />
<field name="reservation_sequence_id" ref="pms.seq_pms_reservation" />
</record>
<!-- users -->
<record id="base.user_root" model="res.users">

View File

@@ -67,13 +67,6 @@ class PmsProperty(models.Model):
copy=False,
comodel_name="ir.sequence",
)
reservation_sequence_id = fields.Many2one(
string="Reservation Sequence",
help="The sequence that formed the name of the reservation.",
check_company=True,
copy=False,
comodel_name="ir.sequence",
)
checkin_sequence_id = fields.Many2one(
string="Checkin Sequence",
help="Field used to create the name of the checkin partner",
@@ -510,20 +503,6 @@ class PmsProperty(models.Model):
}
)
vals.update({"folio_sequence_id": folio_sequence.id})
if "reservation_sequence_id" not in vals or not vals.get(
"reservation_sequence_id"
):
reservation_sequence = self.env["ir.sequence"].create(
{
"name": "PMS Reservation " + name,
"code": "pms.reservation",
"prefix": "R/%(y)s",
"suffix": "%(sec)s",
"padding": 4,
"company_id": vals.get("company_id"),
}
)
vals.update({"reservation_sequence_id": reservation_sequence.id})
if "checkin_sequence_id" not in vals or not vals.get("checkin_sequence_id"):
checkin_sequence = self.env["ir.sequence"].create(
{

View File

@@ -26,6 +26,11 @@ class PmsReservation(models.Model):
help="Reservation Code Identification",
readonly=True,
)
folio_sequence = fields.Integer(
string="Folio Sequence",
help="Techinal field to get reservation name",
readonly=True,
)
priority = fields.Integer(
string="Priority",
help="Priority of a reservation",
@@ -1878,14 +1883,13 @@ class PmsReservation(models.Model):
else:
raise ValidationError(_("The Property are mandatory in the reservation"))
if vals.get("name", _("New")) == _("New") or "name" not in vals:
pms_property_id = (
self.env.user.get_active_property_ids()[0]
if "pms_property_id" not in vals
else vals["pms_property_id"]
folio_sequence = (
max(folio.mapped("reservation_ids.folio_sequence")) + 1
if folio.reservation_ids
else 1
)
pms_property = self.env["pms.property"].browse(pms_property_id)
vals["name"] = pms_property.reservation_sequence_id._next_do()
vals["folio_sequence"] = folio_sequence
vals["name"] = folio.name + "/" + str(folio_sequence)
if not vals.get("reservation_type"):
vals["reservation_type"] = (
folio.reservation_type if folio.reservation_type else "normal"

View File

@@ -781,5 +781,8 @@ class ResPartner(models.Model):
"pms", "various_pms_partner"
)
if various_partner_id in self.ids:
raise ValidationError(_("The partner 'Various Clients' cannot be deleted"))
various_partner = self.browse(various_partner_id)
raise ValidationError(
_("The partner %s cannot be deleted"), various_partner.name
)
return super().unlink()

View File

@@ -69,7 +69,6 @@
</group>
<group string="Sequences">
<field name="folio_sequence_id" />
<field name="reservation_sequence_id" />
<field name="checkin_sequence_id" />
</group>
<group colspan="4" col="4" string="Check-in hours">