diff --git a/pms/models/pms_checkin_partner.py b/pms/models/pms_checkin_partner.py index db10d834e..43e267065 100644 --- a/pms/models/pms_checkin_partner.py +++ b/pms/models/pms_checkin_partner.py @@ -213,11 +213,11 @@ class PmsCheckinPartner(models.Model): compute="_compute_partner_incongruences", ) - possible_existing_customer_ids = fields.Many2one( + is_possible_existing_customer_id = fields.Many2one( string="Possible existing customer", readonly=False, store=True, - compute="_compute_possible_existing_customer_ids", + compute="_compute_is_possible_existing_customer_id", ) add_possible_customer = fields.Boolean(string="Add possible Customer") @@ -420,9 +420,9 @@ class PmsCheckinPartner(models.Model): self.env["pms.folio"]._add_customer(record) @api.depends("email", "mobile") - def _compute_possible_existing_customer_ids(self): + def _compute_is_possible_existing_customer_id(self): for record in self: - self.env["pms.folio"]._apply_possible_existing_customer_ids(record) + self.env["pms.folio"]._apply_is_possible_existing_customer_id(record) @api.depends( "firstname", diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py index a15bc3887..4d3722511 100644 --- a/pms/models/pms_folio.py +++ b/pms/models/pms_folio.py @@ -469,13 +469,11 @@ class PmsFolio(models.Model): ondelete="restrict", ) - possible_existing_customer_ids = fields.One2many( + is_possible_existing_customer_id = fields.Many2one( string="Possible existing customer", readonly=False, store=True, - compute="_compute_possible_existing_customer_ids", - comodel_name="res.partner", - inverse_name="folio_possible_customer_id", + compute="_compute_is_possible_existing_customer_id", ) add_possible_customer = fields.Boolean(string="Add possible Customer") @@ -1014,9 +1012,9 @@ class PmsFolio(models.Model): self._apply_document_id(record) @api.depends("email", "mobile") - def _compute_possible_existing_customer_ids(self): + def _compute_is_possible_existing_customer_id(self): for record in self: - self._apply_possible_existing_customer_ids(record) + self._apply_is_possible_existing_customer_id(record) def _search_invoice_ids(self, operator, value): if operator == "in" and value: @@ -1778,17 +1776,17 @@ class PmsFolio(models.Model): record.email = False @api.model - def _apply_possible_existing_customer_ids(self, record): + def _apply_is_possible_existing_customer_id(self, record): if record.email and not record.partner_id: - record.possible_existing_customer_ids = self.env["res.partner"].search( - [("email", "=", record.email)] + record.is_possible_existing_customer_id = ( + self.env["res.partner"].search([("email", "=", record.email)]).id ) elif record.mobile and not record.partner_id: - record.possible_existing_customer_ids = self.env["res.partner"].search( - [("mobile", "=", record.mobile)] + record.is_possible_existing_customer_id = ( + self.env["res.partner"].search([("mobile", "=", record.mobile)]).id ) else: - record.possible_existing_customer_ids = False + record.is_possible_existing_customer_id = False @api.model def _apply_document_id(self, record): @@ -1863,7 +1861,7 @@ class PmsFolio(models.Model): # and therefore also the document_number, email or mobile @api.model def _add_customer(self, record): - record.partner_id = record.possible_existing_customer_ids.id + record.partner_id = record.is_possible_existing_customer_id.id record._compute_document_number() record._compute_email() record._compute_mobile() diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index e19583055..3e0715b33 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -635,13 +635,11 @@ class PmsReservation(models.Model): ondelete="restrict", ) - possible_existing_customer_ids = fields.One2many( + is_possible_existing_customer_id = fields.Many2one( string="Possible existing customer", readonly=False, store=True, - compute="_compute_possible_existing_customer_ids", - comodel_name="res.partner", - inverse_name="reservation_possible_customer_id", + compute="_compute_is_possible_existing_customer_id", ) add_possible_customer = fields.Boolean(string="Add possible Customer") @@ -1439,9 +1437,9 @@ class PmsReservation(models.Model): self.env["pms.folio"]._apply_document_id(record) @api.depends("email", "mobile") - def _compute_possible_existing_customer_ids(self): + def _compute_is_possible_existing_customer_id(self): for record in self: - self.env["pms.folio"]._apply_possible_existing_customer_ids(record) + self.env["pms.folio"]._apply_is_possible_existing_customer_id(record) @api.depends("checkin", "checkout") def _compute_is_modified_reservation(self): diff --git a/pms/models/res_partner.py b/pms/models/res_partner.py index 60b175a3f..e8291423c 100644 --- a/pms/models/res_partner.py +++ b/pms/models/res_partner.py @@ -126,12 +126,6 @@ class ResPartner(models.Model): comment = fields.Text( tracking=True, ) - reservation_possible_customer_id = fields.Many2one( - string="Possible Customer In Reservation", comodel_name="pms.reservation" - ) - folio_possible_customer_id = fields.Many2one( - string="Possible Customer In Folio", comodel_name="pms.folio" - ) @api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.gender") def _compute_gender(self): diff --git a/pms/tests/__init__.py b/pms/tests/__init__.py index 513ff1636..43e0a2cbe 100644 --- a/pms/tests/__init__.py +++ b/pms/tests/__init__.py @@ -19,23 +19,23 @@ # along with this program. If not, see . # ############################################################################## -# from . import test_pms_reservation -# from . import test_pms_pricelist -# from . import test_pms_checkin_partner -# from . import test_pms_sale_channel -# from . import test_pms_folio -# from . import test_pms_availability_plan_rules -# from . import test_pms_room_type -# from . import test_pms_room_type_class -# from . import test_pms_board_service -# from . import test_pms_wizard_massive_changes -# from . import test_pms_booking_engine -# from . import test_pms_res_users -# from . import test_pms_room -# from . import test_pms_folio_invoice -# from . import test_pms_folio_sale_line -# from . import test_pms_wizard_split_join_swap_reservation -# from . import test_product_template -# from . import test_pms_multiproperty -# from . import test_shared_room +from . import test_pms_reservation +from . import test_pms_pricelist +from . import test_pms_checkin_partner +from . import test_pms_sale_channel +from . import test_pms_folio +from . import test_pms_availability_plan_rules +from . import test_pms_room_type +from . import test_pms_room_type_class +from . import test_pms_board_service +from . import test_pms_wizard_massive_changes +from . import test_pms_booking_engine +from . import test_pms_res_users +from . import test_pms_room +from . import test_pms_folio_invoice +from . import test_pms_folio_sale_line +from . import test_pms_wizard_split_join_swap_reservation +from . import test_product_template +from . import test_pms_multiproperty +from . import test_shared_room from . import test_automated_mails diff --git a/pms/tests/test_automated_mails.py b/pms/tests/test_automated_mails.py index 4a7cf9ad8..8f60d2abd 100644 --- a/pms/tests/test_automated_mails.py +++ b/pms/tests/test_automated_mails.py @@ -1,16 +1,26 @@ from odoo.exceptions import UserError + from .common import TestPms class TestPmsAutomatedMails(TestPms): def setUp(self): super().setUp() - self.template = self.env["mail.template"].search([("name", "=", "Confirmed Reservation")]) + self.template = self.env["mail.template"].search( + [("name", "=", "Confirmed Reservation")] + ) def test_create_automated_action(self): + """ + Checks that an automated_action is created correctly when an + automated_mail is created. + --------------------- + An automated_mail is created and then it is verified that + the automated_action was created. + """ # ARRANGE automated_mail_vals = { - "name": 'Auto Mail 1', + "name": "Auto Mail 1", "template_id": self.template.id, "action": "creation", "moment": "in_act", @@ -22,14 +32,21 @@ class TestPmsAutomatedMails(TestPms): # ASSERT self.assertTrue( - auto_mail.automated_actions_id, - "Automated action should be created " + auto_mail.automated_actions_id, "Automated action should be created " ) def test_no_action_creation_before(self): + """ + Check that an automated mail cannot be created with action='creation' + and moment='before'. + ----------------------- + An automated mail is created with action = 'creation' and moment = 'before'. + Then it is verified that a UserError was thrown because an automated_mail with + these parameters cannot be created. + """ # ARRANGE automated_mail_vals = { - "name": 'Auto Mail 1', + "name": "Auto Mail 1", "template_id": self.template.id, "action": "creation", "moment": "before", @@ -40,8 +57,562 @@ class TestPmsAutomatedMails(TestPms): with self.assertRaises( UserError, msg="It should not be allowed to create the automated mail " - "with action 'creation' and moment 'before' values" + "with action 'creation' and moment 'before' values", ): self.env["pms.automated.mails"].create(automated_mail_vals) + def test_trigger_moment_in_act_creation(self): + """ + Check that when creating an automated mail with parameters + action = 'creation' and moment = 'in_act' the trigger of the + automated_action created is 'on_create'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "creation", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_create", + "The trigger of the automated action must be 'on_create'", + ) + + def test_trigger_moment_after_in_creation_action(self): + """ + Check that when creating an automated mail with parameters + action = 'creation' and moment = 'after' the trigger of the + automated_action created is 'on_time'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "creation", + "moment": "after", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 1, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_time", + "The trigger of the automated action must be 'on_time'", + ) + + def test_trigger_moment_in_act_in_write_action(self): + """ + Check that when creating an automated mail with parameters + action = 'write' and moment = 'in_act' the trigger of the + automated_action created is 'on_write'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "write", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_write", + "The trigger of the automated action must be 'on_write'", + ) + + def test_trigger_moment_after_in_write_action(self): + """ + Check that when creating an automated mail with parameters + action = 'write' and moment = 'after' the trigger of the + automated_action created is 'on_time'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "write", + "moment": "after", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 1, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_time", + "The trigger of the automated action must be 'on_time'", + ) + + def test_time_moment_before_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'before' the trg_date_range + of the automated_action created is equal to + (automated_mail.time * -1)'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 60, + "time_type": "minutes", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + -60, + "The trg_date_range of the automated action must be '-60'", + ) + + def test_time_moment_in_act_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'in_act' the trg_date_range + of the automated_action created is equal to 0 + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + 0, + "The trg_date_range of the automated action must be '0'", + ) + + def test_trigger_moment_before_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'before' the trigger of the + automated_action created is 'on_time'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 24, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_time", + "The trigger of the automated action must be 'on_time'", + ) + + def test_trigger_moment_in_act_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'in_act' the trigger of the + automated_action created is 'on_write'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_write", + "The trigger of the automated action must be 'on_write'", + ) + + def test_time_moment_before_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'before' the trg_date_range + of the automated_action created is equal to + (automated_mail.time * -1)'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 60, + "time_type": "minutes", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + -60, + "The trg_date_range of the automated action must be '-60'", + ) + + def test_time_moment_in_act_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'in_act' the trg_date_range + of the automated_action created is equal to 0. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + 0, + "The trg_date_range of the automated action must be '0'", + ) + + def test_trigger_moment_before_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'before' the trigger of the + automated_action created is 'on_time'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 24, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_time", + "The trigger of the automated action must be 'on_time'", + ) + + def test_trigger_moment_in_act_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'in_act' the trigger of the + automated_action created is 'on_write'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_write", + "The trigger of the automated action must be 'on_write'", + ) + + def test_trigger_moment_in_act_in_payment_action(self): + """ + Check that when creating an automated mail with parameters + action = 'payment' and moment = 'in_act' the trigger of the + automated_action created is 'on_create'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "payment", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_create", + "The trigger of the automated action must be 'on_create'", + ) + + def test_trigger_moment_before_in_payment_action(self): + """ + Check that when creating an automated mail with parameters + action = 'payment' and moment = 'before' the trigger of the + automated_action created is 'on_time'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "payment", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 24, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_time", + "The trigger of the automated action must be 'on_time'", + ) + + def test_time_moment_before_in_payment_action(self): + """ + Check that when creating an automated mail with parameters + action = 'payment' and moment = 'before' the trg_date_range + field of the automated_action is (automated_mail.time * -1). + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "payment", + "moment": "before", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + "time": 24, + "time_type": "hour", + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + -24, + "The trg_date_range of the automated action must be '-24'", + ) + + def test_trigger_moment_in_act_in_invoice_action(self): + """ + Check that when creating an automated mail with parameters + action = 'invoice' and moment = 'in_act' the trigger field + of the automated_action created is 'on_create'. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "invoice", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trigger, + "on_create", + "The trigger of the automated action must be 'on_create'", + ) + + def test_time_moment_in_act_in_invoice_action(self): + """ + Check that when creating an automated mail with parameters + action = 'invoice' and moment = 'in_act' the trg_date_range + field of the automated_action is 0. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "invoice", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.trg_date_range, + 0, + "The trg_date_range of the automated action must be '0'", + ) + + def test_filter_pre_domain_moment_in_act_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'in_act' the filter_pre_domain + field of the automated_action is [('state', '=', 'confirm')]. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.filter_pre_domain, + "[('state', '=', 'confirm')]", + "The filter_pre_domain of the automated action " + "must be '[('state', '=', 'confirm')]'", + ) + + def test_filter_domain_moment_in_act_in_checkin(self): + """ + Check that when creating an automated mail with parameters + action = 'checkin' and moment = 'in_act' the filter_domain + field of the automated_action is + [('state', '=', 'onboard'), ('pms_property_id', '=', [value of property_id.id])]]. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkin", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + pms_property_id_str = str(auto_mail.pms_property_ids.ids) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.filter_domain, + "[('state', '=', 'onboard'), ('pms_property_id', 'in', " + + pms_property_id_str + + ")]", + "The filter_domain of the automated action must be " + "'[('state', '=', 'onboard'), " + "('pms_property_id', '=', [value of property_id.id])]'", + ) + + def test_filter_pre_domain_moment_in_act_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'in_act' the filter_pre_domain + field of the automated_action is [('state', '=', 'onboard')]. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.filter_pre_domain, + "[('state', '=', 'onboard')]", + "The filter_pre_domain of the automated action must " + "be '[('state', '=', 'onboard')]'", + ) + + def test_filter_domain_moment_in_act_in_checkout(self): + """ + Check that when creating an automated mail with parameters + action = 'checkout' and moment = 'in_act' the filter_domain + field of the automated_action is + [('state', '=', 'out'), ('pms_property_id', '=', [value of property_id.id])]]. + """ + # ARRANGE + automated_mail_vals = { + "name": "Auto Mail 1", + "template_id": self.template.id, + "action": "checkout", + "moment": "in_act", + "pms_property_ids": [(6, 0, [self.pms_property1.id])], + } + + # ACT + auto_mail = self.env["pms.automated.mails"].create(automated_mail_vals) + pms_property_id_str = str(auto_mail.pms_property_ids.ids) + + # ASSERT + self.assertEqual( + auto_mail.automated_actions_id.filter_domain, + "[('state', '=', 'out'), ('pms_property_id', 'in', " + + pms_property_id_str + + ")]", + "The filter_pre_domain of the automated action must " + "be '[('state', '=', 'out'), ('pms_property_id', '=', [value of property_id.id])]", + ) diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py index ec0442e12..c7c48f119 100644 --- a/pms/tests/test_pms_reservation.py +++ b/pms/tests/test_pms_reservation.py @@ -3466,3 +3466,35 @@ class TestPmsReservations(TestPms): reservation.is_modified_reservation, "is_modified_reservation field should be True ", ) + + def test_is_not_modified_reservation(self): + """ + Checked that the is_modified_reservation field is correctly set + to False when the reservation is modified but not the checkin + or checkout fields. + ---------------------- + A reservation is created. The adults, arrival_hour and departure_hours + fields of the reservation are modified.The it is verified that the state + of this field is False. + """ + # ARRANGE + checkin = fields.date.today() + checkout = fields.date.today() + datetime.timedelta(days=2) + reservation_vals = { + "checkin": checkin, + "checkout": checkout, + "room_type_id": self.room_type_double.id, + "partner_id": self.partner1.id, + "pms_property_id": self.pms_property1.id, + } + + reservation = self.env["pms.reservation"].create(reservation_vals) + reservation.update( + {"adults": 1, "arrival_hour": "18:00", "departure_hour": "08:00"} + ) + + # ASSERT + self.assertFalse( + reservation.is_modified_reservation, + "is_modified_reservation field should be False ", + ) diff --git a/pms/views/pms_checkin_partner_views.xml b/pms/views/pms_checkin_partner_views.xml index a4922873e..50aa60cfe 100644 --- a/pms/views/pms_checkin_partner_views.xml +++ b/pms/views/pms_checkin_partner_views.xml @@ -42,13 +42,13 @@ class="alert alert-warning" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': [('possible_existing_customer_ids','=',False)]}" + attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}" > There is a customer with this email or mobile, do you want to add it to the reservation? - + diff --git a/pms/views/pms_folio_views.xml b/pms/views/pms_folio_views.xml index 4942c6baf..572cbd1f1 100644 --- a/pms/views/pms_folio_views.xml +++ b/pms/views/pms_folio_views.xml @@ -59,13 +59,13 @@ class="alert alert-warning" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': [('possible_existing_customer_ids','=',False)]}" + attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}" > There is a customer with this email or mobile, do you want to add it to the reservation? - + diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml index b6fde816d..233b62735 100644 --- a/pms/views/pms_reservation_views.xml +++ b/pms/views/pms_reservation_views.xml @@ -140,13 +140,13 @@ class="alert alert-warning" role="alert" style="margin-bottom:0px;" - attrs="{'invisible': [('possible_existing_customer_ids','=',[])]}" + attrs="{'invisible': [('is_possible_existing_customer_id','=',[])]}" > There is a customer with this email or mobile, do you want to add it to the reservation? - + diff --git a/pms/wizards/__init__.py b/pms/wizards/__init__.py index f6f5db47e..3833141ff 100644 --- a/pms/wizards/__init__.py +++ b/pms/wizards/__init__.py @@ -5,4 +5,3 @@ from . import pms_booking_engine from . import folio_make_invoice_advance from . import wizard_payment_folio from . import wizard_folio_changes -from . import wizard_several_partners