[IMP]test in pms_automated_mails and pms_reservation

This commit is contained in:
braisab
2021-09-12 23:04:06 +02:00
parent 9e7b76da99
commit 8ea8e7976c
11 changed files with 656 additions and 64 deletions

View File

@@ -213,11 +213,11 @@ class PmsCheckinPartner(models.Model):
compute="_compute_partner_incongruences", compute="_compute_partner_incongruences",
) )
possible_existing_customer_ids = fields.Many2one( is_possible_existing_customer_id = fields.Many2one(
string="Possible existing customer", string="Possible existing customer",
readonly=False, readonly=False,
store=True, store=True,
compute="_compute_possible_existing_customer_ids", compute="_compute_is_possible_existing_customer_id",
) )
add_possible_customer = fields.Boolean(string="Add possible Customer") add_possible_customer = fields.Boolean(string="Add possible Customer")
@@ -420,9 +420,9 @@ class PmsCheckinPartner(models.Model):
self.env["pms.folio"]._add_customer(record) self.env["pms.folio"]._add_customer(record)
@api.depends("email", "mobile") @api.depends("email", "mobile")
def _compute_possible_existing_customer_ids(self): def _compute_is_possible_existing_customer_id(self):
for record in 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( @api.depends(
"firstname", "firstname",

View File

@@ -469,13 +469,11 @@ class PmsFolio(models.Model):
ondelete="restrict", ondelete="restrict",
) )
possible_existing_customer_ids = fields.One2many( is_possible_existing_customer_id = fields.Many2one(
string="Possible existing customer", string="Possible existing customer",
readonly=False, readonly=False,
store=True, store=True,
compute="_compute_possible_existing_customer_ids", compute="_compute_is_possible_existing_customer_id",
comodel_name="res.partner",
inverse_name="folio_possible_customer_id",
) )
add_possible_customer = fields.Boolean(string="Add possible Customer") add_possible_customer = fields.Boolean(string="Add possible Customer")
@@ -1014,9 +1012,9 @@ class PmsFolio(models.Model):
self._apply_document_id(record) self._apply_document_id(record)
@api.depends("email", "mobile") @api.depends("email", "mobile")
def _compute_possible_existing_customer_ids(self): def _compute_is_possible_existing_customer_id(self):
for record in 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): def _search_invoice_ids(self, operator, value):
if operator == "in" and value: if operator == "in" and value:
@@ -1778,17 +1776,17 @@ class PmsFolio(models.Model):
record.email = False record.email = False
@api.model @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: if record.email and not record.partner_id:
record.possible_existing_customer_ids = self.env["res.partner"].search( record.is_possible_existing_customer_id = (
[("email", "=", record.email)] self.env["res.partner"].search([("email", "=", record.email)]).id
) )
elif record.mobile and not record.partner_id: elif record.mobile and not record.partner_id:
record.possible_existing_customer_ids = self.env["res.partner"].search( record.is_possible_existing_customer_id = (
[("mobile", "=", record.mobile)] self.env["res.partner"].search([("mobile", "=", record.mobile)]).id
) )
else: else:
record.possible_existing_customer_ids = False record.is_possible_existing_customer_id = False
@api.model @api.model
def _apply_document_id(self, record): def _apply_document_id(self, record):
@@ -1863,7 +1861,7 @@ class PmsFolio(models.Model):
# and therefore also the document_number, email or mobile # and therefore also the document_number, email or mobile
@api.model @api.model
def _add_customer(self, record): 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_document_number()
record._compute_email() record._compute_email()
record._compute_mobile() record._compute_mobile()

View File

@@ -635,13 +635,11 @@ class PmsReservation(models.Model):
ondelete="restrict", ondelete="restrict",
) )
possible_existing_customer_ids = fields.One2many( is_possible_existing_customer_id = fields.Many2one(
string="Possible existing customer", string="Possible existing customer",
readonly=False, readonly=False,
store=True, store=True,
compute="_compute_possible_existing_customer_ids", compute="_compute_is_possible_existing_customer_id",
comodel_name="res.partner",
inverse_name="reservation_possible_customer_id",
) )
add_possible_customer = fields.Boolean(string="Add possible Customer") 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) self.env["pms.folio"]._apply_document_id(record)
@api.depends("email", "mobile") @api.depends("email", "mobile")
def _compute_possible_existing_customer_ids(self): def _compute_is_possible_existing_customer_id(self):
for record in 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") @api.depends("checkin", "checkout")
def _compute_is_modified_reservation(self): def _compute_is_modified_reservation(self):

View File

@@ -126,12 +126,6 @@ class ResPartner(models.Model):
comment = fields.Text( comment = fields.Text(
tracking=True, 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") @api.depends("pms_checkin_partner_ids", "pms_checkin_partner_ids.gender")
def _compute_gender(self): def _compute_gender(self):

View File

@@ -19,23 +19,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
# from . import test_pms_reservation from . import test_pms_reservation
# from . import test_pms_pricelist from . import test_pms_pricelist
# from . import test_pms_checkin_partner from . import test_pms_checkin_partner
# from . import test_pms_sale_channel from . import test_pms_sale_channel
# from . import test_pms_folio from . import test_pms_folio
# from . import test_pms_availability_plan_rules from . import test_pms_availability_plan_rules
# from . import test_pms_room_type from . import test_pms_room_type
# from . import test_pms_room_type_class from . import test_pms_room_type_class
# from . import test_pms_board_service from . import test_pms_board_service
# from . import test_pms_wizard_massive_changes from . import test_pms_wizard_massive_changes
# from . import test_pms_booking_engine from . import test_pms_booking_engine
# from . import test_pms_res_users from . import test_pms_res_users
# from . import test_pms_room from . import test_pms_room
# from . import test_pms_folio_invoice from . import test_pms_folio_invoice
# from . import test_pms_folio_sale_line from . import test_pms_folio_sale_line
# from . import test_pms_wizard_split_join_swap_reservation from . import test_pms_wizard_split_join_swap_reservation
# from . import test_product_template from . import test_product_template
# from . import test_pms_multiproperty from . import test_pms_multiproperty
# from . import test_shared_room from . import test_shared_room
from . import test_automated_mails from . import test_automated_mails

View File

@@ -1,16 +1,26 @@
from odoo.exceptions import UserError from odoo.exceptions import UserError
from .common import TestPms from .common import TestPms
class TestPmsAutomatedMails(TestPms): class TestPmsAutomatedMails(TestPms):
def setUp(self): def setUp(self):
super().setUp() 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): 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 # ARRANGE
automated_mail_vals = { automated_mail_vals = {
"name": 'Auto Mail 1', "name": "Auto Mail 1",
"template_id": self.template.id, "template_id": self.template.id,
"action": "creation", "action": "creation",
"moment": "in_act", "moment": "in_act",
@@ -22,14 +32,21 @@ class TestPmsAutomatedMails(TestPms):
# ASSERT # ASSERT
self.assertTrue( self.assertTrue(
auto_mail.automated_actions_id, auto_mail.automated_actions_id, "Automated action should be created "
"Automated action should be created "
) )
def test_no_action_creation_before(self): 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 # ARRANGE
automated_mail_vals = { automated_mail_vals = {
"name": 'Auto Mail 1', "name": "Auto Mail 1",
"template_id": self.template.id, "template_id": self.template.id,
"action": "creation", "action": "creation",
"moment": "before", "moment": "before",
@@ -40,8 +57,562 @@ class TestPmsAutomatedMails(TestPms):
with self.assertRaises( with self.assertRaises(
UserError, UserError,
msg="It should not be allowed to create the automated mail " 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) 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])]",
)

View File

@@ -3466,3 +3466,35 @@ class TestPmsReservations(TestPms):
reservation.is_modified_reservation, reservation.is_modified_reservation,
"is_modified_reservation field should be True ", "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 ",
)

View File

@@ -42,13 +42,13 @@
class="alert alert-warning" class="alert alert-warning"
role="alert" role="alert"
style="margin-bottom:0px;" 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? There is a customer with this email or mobile, do you want to add it to the reservation?
<field name="possible_existing_customer_ids" invisible="1" /> <field name="is_possible_existing_customer_id" invisible="1" />
<field <field
name="add_possible_customer" name="add_possible_customer"
attrs="{'invisible': [('possible_existing_customer_ids','=',False)]}" attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
/> />
</div> </div>
<group name="group_top"> <group name="group_top">

View File

@@ -59,13 +59,13 @@
class="alert alert-warning" class="alert alert-warning"
role="alert" role="alert"
style="margin-bottom:0px;" 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? There is a customer with this email or mobile, do you want to add it to the reservation?
<field name="possible_existing_customer_ids" invisible="1" /> <field name="is_possible_existing_customer_id" invisible="1" />
<field <field
name="add_possible_customer" name="add_possible_customer"
attrs="{'invisible': [('possible_existing_customer_ids','=',False)]}" attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
/> />
</div> </div>
<sheet> <sheet>

View File

@@ -140,13 +140,13 @@
class="alert alert-warning" class="alert alert-warning"
role="alert" role="alert"
style="margin-bottom:0px;" 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? There is a customer with this email or mobile, do you want to add it to the reservation?
<field name="possible_existing_customer_ids" invisible="1" /> <field name="is_possible_existing_customer_id" invisible="1" />
<field <field
name="add_possible_customer" name="add_possible_customer"
attrs="{'invisible': [('possible_existing_customer_ids','=',False)]}" attrs="{'invisible': [('is_possible_existing_customer_id','=',False)]}"
/> />
</div> </div>
<sheet> <sheet>

View File

@@ -5,4 +5,3 @@ from . import pms_booking_engine
from . import folio_make_invoice_advance from . import folio_make_invoice_advance
from . import wizard_payment_folio from . import wizard_payment_folio
from . import wizard_folio_changes from . import wizard_folio_changes
from . import wizard_several_partners