Skip to content

Commit

Permalink
[IMP]pms_l10n_es: allow traveler report account by room
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Dec 15, 2024
1 parent f54b8a6 commit d28ab6a
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 77 deletions.
22 changes: 12 additions & 10 deletions pms_l10n_es/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class PmsReservation(models.Model):
("processed", "Processed"),
],
compute="_compute_ses_status_reservation",
store=True,
)
ses_status_traveller_report = fields.Selection(
string="SES Status traveller",
Expand All @@ -46,15 +45,20 @@ class PmsReservation(models.Model):
("processed", "Processed"),
],
compute="_compute_ses_status_traveller_report",
store=True,
)

@api.depends("pms_property_id")
@api.depends("pms_property_id", "preferred_room_id")
def _compute_is_ses(self):
for record in self:
record.is_ses = record.pms_property_id.institution == "ses"
if (
record.preferred_room_id
and record.institution_independent_account
and record.preferred_room_id.institution == "ses"
):
record.is_ses = True
else:
record.is_ses = record.pms_property_id.institution == "ses"

@api.depends("ses_communication_ids", "ses_communication_ids.state")
def _compute_ses_status_reservation(self):
for record in self:
if record.pms_property_id.institution != "ses":
Expand All @@ -70,7 +74,6 @@ def _compute_ses_status_reservation(self):
communication.state if communication else "error_create"
)

@api.depends("ses_communication_ids", "ses_communication_ids.state")
def _compute_ses_status_traveller_report(self):
for record in self:
if record.pms_property_id.institution != "ses":
Expand All @@ -88,11 +91,13 @@ def _compute_ses_status_traveller_report(self):

@api.model
def create_communication(self, reservation_id, operation, entity):
reservation = self.env["pms.reservation"].browse(reservation_id)
self.env["pms.ses.communication"].create(
{
"reservation_id": reservation_id,
"operation": operation,
"entity": entity,
"room_id": reservation.preferred_room_id.id,
}
)

Expand Down Expand Up @@ -164,9 +169,6 @@ def create_communication_after_update_reservation(self, reservation, vals):

def write(self, vals):
for record in self:
if (
record.pms_property_id.institution == "ses"
and record.reservation_type != "out"
):
if record.is_ses and record.reservation_type != "out":
self.create_communication_after_update_reservation(record, vals)
return super(PmsReservation, self).write(vals)
35 changes: 35 additions & 0 deletions pms_l10n_es/models/pms_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,43 @@

class PmsRoom(models.Model):
_inherit = "pms.room"

in_ine = fields.Boolean(
string="In INE",
help="Take it into account to generate INE statistics",
default=True,
)
institution_independent_account = fields.Boolean(
string="Independent account for institution (travel reports)",
help="This room has an independent account",
default=False,
)
institution = fields.Selection(
[
("ses", "SES"),
("ertxaintxa", "Ertxaintxa (soon)"),
("mossos", "Mossos_d'esquadra (soon)"),
],
string="Institution",
help="Institution to send daily guest data.",
required=False,
)
institution_property_id = fields.Char(
string="Institution property id",
help="Id provided by institution to send data from property.",
)
ses_url = fields.Char(
string="SES URL",
help="URL to send the data to SES",
)
institution_user = fields.Char(
string="Institution user", help="User provided by institution to send the data."
)
institution_password = fields.Char(
string="Institution password",
help="Password provided by institution to send the data.",
)
institution_lessor_id = fields.Char(
string="Institution lessor id",
help="Id provided by institution to send data from lessor.",
)
8 changes: 8 additions & 0 deletions pms_l10n_es/models/pms_ses_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class PmsSesCommunication(models.Model):
index=True,
store=True,
)
room_id = fields.Many2one(
comodel_name="pms.room",
string="Room",
help="Room related to this communication",
related="reservation_id.preferred_room_id",
index=True,
store=True,
)
batch_id = fields.Char(
string="Batch ID",
default=False,
Expand Down
16 changes: 16 additions & 0 deletions pms_l10n_es/views/pms_room_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='sequence']" position="after">
<field name="in_ine" />
<field name="ses_indepent_account" />
</xpath>
<xpath expr="//notebook" position="inside">
<page
string="Travel record institution"
attrs="{'invisible': [('ses_independent_account', '=', False)]}"
>
<group>
<field name="institution" />
<field name="institution_property_id" />
<field name="institution_lessor_id" />
<field name="ses_url" />
<field name="institution_user" />
<field name="institution_password" />
</group>
</page>
</xpath>
</field>
</record>
Expand Down
Loading

0 comments on commit d28ab6a

Please sign in to comment.