diff --git a/README.md b/README.md
index c2641ba83..8b3c2a7df 100644
--- a/README.md
+++ b/README.md
@@ -20,9 +20,9 @@ Available addons
addon | version | summary
--- | --- | ---
[multi_pms_properties](multi_pms_properties/) | 14.0.1.0.0 | Multi Properties Manager
-[pms](pms/) | 14.0.1.0.8 | A property management system
+[pms](pms/) | 14.0.1.0.10 | A property management system
[pms_housekeeping](pms_housekeeping/) | 14.0.1.0.1 | Housekeeping
-[pms_l10n_es](pms_l10n_es/) | 14.0.1.0.1 | PMS Spanish Adaptation
+[pms_l10n_es](pms_l10n_es/) | 14.0.1.0.2 | PMS Spanish Adaptation
[pms_rooming_xls](pms_rooming_xls/) | 14.0.1.0.0 | Rooming xlsx Management
[//]: # (end addons)
diff --git a/pms/__manifest__.py b/pms/__manifest__.py
index a23f62756..18035fc6e 100644
--- a/pms/__manifest__.py
+++ b/pms/__manifest__.py
@@ -4,7 +4,7 @@
{
"name": "PMS (Property Management System)",
"summary": "A property management system",
- "version": "14.0.1.0.8",
+ "version": "14.0.1.0.10",
"development_status": "Alpha",
"category": "Generic Modules/Property Management System",
"website": "https://github.com/OCA/pms",
diff --git a/pms/i18n/es.po b/pms/i18n/es.po
index 796b4b109..55e0afa32 100644
--- a/pms/i18n/es.po
+++ b/pms/i18n/es.po
@@ -72,8 +72,8 @@ msgstr "%s no encontrado en los checkins (%s)"
#. module: pms
#: code:addons/pms/models/pms_reservation_line.py:0
#, python-format
-msgid "%s: No room available."
-msgstr "%s: Habitación no disponible."
+msgid "%s: No room available in %s <-> %s."
+msgstr ""
#. module: pms
#: code:addons/pms/models/pms_reservation_line.py:0
@@ -6457,6 +6457,12 @@ msgstr "Línea de la Reserva"
msgid "Reservation availability plan"
msgstr "Plan de Disponibilidad de la Reserva"
+#. module: pms
+#: code:addons/pms/models/pms_reservation.py:0
+#, python-format
+msgid "Reservation dates should be consecutives"
+msgstr ""
+
#. module: pms
#: model:ir.model.fields,help:pms.field_pms_service__reservation_id
msgid "Reservation in which the service is included"
@@ -7800,6 +7806,12 @@ msgstr "La capacidad de la habitación debe ser mayor que 0."
msgid "The checkin partners on a folio"
msgstr ""
+#. module: pms
+#: code:addons/pms/models/pms_reservation.py:0
+#, python-format
+msgid "The checkout date must be greater than the checkin date"
+msgstr ""
+
#. module: pms
#: code:addons/pms/models/res_users.py:0
#, python-format
@@ -9042,6 +9054,9 @@ msgid ""
"you cannot have more than one room with the same name in the same property"
msgstr ""
+#~ msgid "%s: No room available."
+#~ msgstr "%s: Habitación no disponible."
+
#, fuzzy
#~ msgid "Technical field"
#~ msgstr "Computación técnica"
diff --git a/pms/i18n/pms.pot b/pms/i18n/pms.pot
index 0f6084647..012e01543 100644
--- a/pms/i18n/pms.pot
+++ b/pms/i18n/pms.pot
@@ -60,7 +60,7 @@ msgstr ""
#. module: pms
#: code:addons/pms/models/pms_reservation_line.py:0
#, python-format
-msgid "%s: No room available."
+msgid "%s: No room available in %s <-> %s."
msgstr ""
#. module: pms
@@ -6129,6 +6129,12 @@ msgstr ""
msgid "Reservation availability plan"
msgstr ""
+#. module: pms
+#: code:addons/pms/models/pms_reservation.py:0
+#, python-format
+msgid "Reservation dates should be consecutives"
+msgstr ""
+
#. module: pms
#: model:ir.model.fields,help:pms.field_pms_service__reservation_id
msgid "Reservation in which the service is included"
@@ -7419,6 +7425,12 @@ msgstr ""
msgid "The checkin partners on a folio"
msgstr ""
+#. module: pms
+#: code:addons/pms/models/pms_reservation.py:0
+#, python-format
+msgid "The checkout date must be greater than the checkin date"
+msgstr ""
+
#. module: pms
#: code:addons/pms/models/res_users.py:0
#, python-format
diff --git a/pms/models/pms_folio.py b/pms/models/pms_folio.py
index 1899af850..802eca458 100644
--- a/pms/models/pms_folio.py
+++ b/pms/models/pms_folio.py
@@ -140,7 +140,6 @@ class PmsFolio(models.Model):
commission = fields.Float(
string="Commission",
readonly=True,
- default=0,
store=True,
compute="_compute_commission",
)
@@ -642,7 +641,7 @@ class PmsFolio(models.Model):
or False
)
- @api.depends("reservation_ids")
+ @api.depends("reservation_ids", "reservation_ids.commission_amount")
def _compute_commission(self):
for folio in self:
for reservation in folio.reservation_ids:
diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py
index 396f15668..607abc5bd 100644
--- a/pms/models/pms_reservation.py
+++ b/pms/models/pms_reservation.py
@@ -109,6 +109,7 @@ class PmsReservation(models.Model):
readonly=False,
store=True,
related="folio_id.agency_id",
+ depends=["folio_id.agency_id"],
tracking=True,
)
channel_type_id = fields.Many2one(
@@ -376,16 +377,18 @@ class PmsReservation(models.Model):
checkin = fields.Date(
string="Check In",
help="It is the checkin date of the reservation, ",
- required=True,
- default=lambda self: self._get_default_checkin(),
+ compute="_compute_checkin",
+ readonly=False,
+ store=True,
copy=False,
tracking=True,
)
checkout = fields.Date(
string="Check Out",
help="It is the checkout date of the reservation, ",
- required=True,
- default=lambda self: self._get_default_checkout(),
+ compute="_compute_checkout",
+ readonly=False,
+ store=True,
copy=False,
tracking=True,
)
@@ -924,6 +927,53 @@ class PmsReservation(models.Model):
for reservation in self:
reservation.access_url = "/my/reservations/%s" % (reservation.id)
+ @api.depends("reservation_line_ids")
+ def _compute_checkin(self):
+ """
+ Allows to calculate the checkin by default or when the create
+ specifically indicates the lines of the reservation
+ """
+ for record in self:
+ if record.reservation_line_ids:
+ checkin_line_date = min(record.reservation_line_ids.mapped("date"))
+ # check if the checkin was created directly as reservation_line_id:
+ if checkin_line_date != record.checkin:
+ record.checkin = checkin_line_date
+ elif not record.checkin:
+ # default checkout other folio reservations or today
+ if len(record.folio_id.reservation_ids) > 1:
+ record.checkin = record.folio_id.reservation_ids[0].checkin
+ else:
+ record.checkin = fields.date.today()
+
+ @api.depends("reservation_line_ids", "checkin")
+ def _compute_checkout(self):
+ """
+ Allows to calculate the checkout by default or when the create
+ specifically indicates the lines of the reservation
+ """
+ for record in self:
+ if record.reservation_line_ids:
+ checkout_line_date = max(
+ record.reservation_line_ids.mapped("date")
+ ) + datetime.timedelta(days=1)
+ # check if the checkout was created directly as reservation_line_id:
+ if checkout_line_date != record.checkout:
+ record.checkout = checkout_line_date
+ # default checkout if checkin is set
+ elif record.checkin and not record.checkout:
+ if len(record.folio_id.reservation_ids) > 1:
+ record.checkin = record.folio_id.reservation_ids[0].checkout
+ else:
+ record.checkout = record.checkin + datetime.timedelta(days=1)
+ elif not record.checkout:
+ record.checkout = False
+ # date checking
+ if record.checkin and record.checkout and record.checkin >= record.checkout:
+ raise UserError(
+ _("The checkout date must be greater than the checkin date")
+ )
+
@api.depends("pms_property_id", "folio_id")
def _compute_arrival_hour(self):
for record in self:
@@ -975,7 +1025,7 @@ class PmsReservation(models.Model):
for reservation in self:
if reservation.commission_percent > 0:
reservation.commission_amount = (
- reservation.price_total * reservation.commission_percent
+ reservation.price_total * reservation.commission_percent / 100
)
else:
reservation.commission_amount = 0
@@ -1184,28 +1234,6 @@ class PmsReservation(models.Model):
recs = self.search([]).filtered(lambda x: x.checkin_partner_pending_count > 0)
return [("id", "in", [x.id for x in recs])] if recs else []
- def _get_default_checkin(self):
- folio = False
- if "folio_id" in self._context:
- folio = self.env["pms.folio"].search(
- [("id", "=", self._context["folio_id"])]
- )
- if folio and folio.reservation_ids:
- return folio.reservation_ids[0].checkin
- else:
- return fields.Date.today()
-
- def _get_default_checkout(self):
- folio = False
- if "folio_id" in self._context:
- folio = self.env["pms.folio"].search(
- [("id", "=", self._context["folio_id"])]
- )
- if folio and folio.reservation_ids:
- return folio.reservation_ids[0].checkout
- else:
- return fields.Date.today() + datetime.timedelta(1)
-
def _get_default_segmentation(self):
folio = False
segmentation_ids = False
@@ -1234,6 +1262,20 @@ class PmsReservation(models.Model):
)
)
+ @api.constrains("reservation_line_ids")
+ def check_consecutive_dates(self):
+ """
+ simply convert date objects to integers using the .toordinal() method
+ of datetime objects. The difference between the maximum and minimum value
+ of the set of ordinal dates is one more than the length of the set
+ """
+ for record in self:
+ if record.reservation_line_ids and len(record.reservation_line_ids) > 1:
+ dates = record.reservation_line_ids.mapped("date")
+ date_ints = {d.toordinal() for d in dates}
+ if not (max(date_ints) - min(date_ints) == len(date_ints) - 1):
+ raise ValidationError(_("Reservation dates should be consecutives"))
+
# @api.constrains("checkin_partner_ids", "adults")
# def _max_checkin_partner_ids(self):
# for record in self:
diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py
index c5f4eaab0..cfdfa06f8 100644
--- a/pms/models/pms_reservation_line.py
+++ b/pms/models/pms_reservation_line.py
@@ -210,8 +210,12 @@ class PmsReservationLine(models.Model):
# if the preferred room is NOT available
else:
raise ValidationError(
- _("%s: No room available.")
- % (reservation.preferred_room_id.name)
+ _("%s: No room available in %s <-> %s.")
+ % (
+ reservation.preferred_room_id.name,
+ line.reservation_id.checkin,
+ line.reservation_id.checkout,
+ )
)
# otherwise we assign the first of those
diff --git a/pms/tests/__init__.py b/pms/tests/__init__.py
index bc18e0a7a..fa95794df 100644
--- a/pms/tests/__init__.py
+++ b/pms/tests/__init__.py
@@ -21,7 +21,6 @@
##############################################################################
from . import test_pms_reservation
from . import test_pms_pricelist
-from . import test_pms_pricelist_priority
from . import test_pms_checkin_partner
from . import test_pms_sale_channel
from . import test_pms_folio
diff --git a/pms/tests/test_pms_folio.py b/pms/tests/test_pms_folio.py
index 7fdeef8c0..2fe41c34e 100644
--- a/pms/tests/test_pms_folio.py
+++ b/pms/tests/test_pms_folio.py
@@ -4,73 +4,34 @@ from freezegun import freeze_time
from odoo import fields
from odoo.exceptions import UserError
-from odoo.tests import common
-freeze_time("2000-02-02")
+from .common import TestPms
-class TestPmsFolio(common.SavepointCase):
- def create_common_scenario(self):
- # create a room type availability
- self.room_type_availability = self.env["pms.availability.plan"].create(
- {"name": "Availability plan for TEST"}
- )
- # sequences
- self.folio_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Folio",
- "code": "pms.folio",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.reservation_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Reservation",
- "code": "pms.reservation",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.checkin_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Checkin",
- "code": "pms.checkin.partner",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- # create a property
- self.property = self.env["pms.property"].create(
- {
- "name": "MY PMS TEST",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
- }
- )
+class TestPmsFolio(TestPms):
- # create room type class
- self.room_type_class = self.env["pms.room.type.class"].create(
- {"name": "Room", "default_code": "ROOM"}
- )
+ # SetUp and Common Scenarios methods
+
+ def setUp(self):
+ """
+ - common + room_type_double with 2 rooms (double1 and double2) in pms_property1
+ """
+ super().setUp()
# create room type
self.room_type_double = self.env["pms.room.type"].create(
{
- "pms_property_ids": [self.property.id],
+ "pms_property_ids": [self.pms_property1.id],
"name": "Double Test",
"default_code": "DBL_Test",
- "class_id": self.room_type_class.id,
+ "class_id": self.room_type_class1.id,
"price": 25,
}
)
# create room
- self.room1 = self.env["pms.room"].create(
+ self.double1 = self.env["pms.room"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"name": "Double 101",
"room_type_id": self.room_type_double.id,
"capacity": 2,
@@ -78,9 +39,9 @@ class TestPmsFolio(common.SavepointCase):
)
# create room
- self.room2 = self.env["pms.room"].create(
+ self.double2 = self.env["pms.room"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"name": "Double 102",
"room_type_id": self.room_type_double.id,
"capacity": 2,
@@ -88,233 +49,344 @@ class TestPmsFolio(common.SavepointCase):
)
def create_multiproperty_scenario(self):
- self.create_common_scenario()
- self.property1 = self.env["pms.property"].create(
- {
- "name": "Property_1",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
- }
- )
-
- self.property2 = self.env["pms.property"].create(
+ """
+ Just 2 properties to majors
+ """
+ self.pms_property2 = self.env["pms.property"].create(
{
"name": "Property_2",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
}
)
- self.property3 = self.env["pms.property"].create(
+ self.pms_property3 = self.env["pms.property"].create(
{
"name": "Property_3",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
}
)
- def test_commission_and_partner_correct(self):
- # ARRANGE
- self.create_common_scenario()
- PmsFolio = self.env["pms.folio"]
- PmsReservation = self.env["pms.reservation"]
+ def create_sale_channel_scenario(self):
+ """
+ Method to simplified scenario on sale channel tests:
+ - create a sale_channel1 like indirect
+ - create a agency1 like sale_channel1 agency
+ """
PmsPartner = self.env["res.partner"]
PmsSaleChannel = self.env["pms.sale.channel"]
- # ACT
- saleChannel = PmsSaleChannel.create(
+
+ self.sale_channel1 = PmsSaleChannel.create(
{"name": "saleChannel1", "channel_type": "indirect"}
)
- agency = PmsPartner.create(
+ self.agency1 = PmsPartner.create(
{
"name": "partner1",
"is_agency": True,
"invoice_to_agency": True,
"default_commission": 15,
- "sale_channel_id": saleChannel.id,
+ "sale_channel_id": self.sale_channel1.id,
}
)
- folio = PmsFolio.create(
+ def create_configuration_accounting_scenario(self):
+ """
+ Method to simplified scenario to payments and accounting:
+ # REVIEW:
+ - Use new property with odoo demo data company to avoid account configuration
+ - Emule SetUp with new property:
+ - create demo_room_type_double
+ - Create 2 rooms room_type_double
+ """
+ self.pms_property_demo = self.env["pms.property"].create(
{
- "agency_id": agency.id,
- "pms_property_id": self.property.id,
+ "name": "Property Based on Comapany Demo",
+ "company_id": self.env.ref("base.main_company").id,
+ "default_pricelist_id": self.env.ref("product.list0").id,
}
)
-
- reservation = PmsReservation.create(
+ # create room type
+ self.demo_room_type_double = self.env["pms.room.type"].create(
{
- "checkin": datetime.datetime.now(),
- "checkout": datetime.datetime.now() + datetime.timedelta(days=3),
- "agency_id": agency.id,
- "folio_id": folio.id,
+ "pms_property_ids": [self.pms_property_demo.id],
+ "name": "Double Test",
+ "default_code": "Demo_DBL_Test",
+ "class_id": self.room_type_class1.id,
+ "price": 25,
}
)
-
- commission = 0
- for reservation in folio.reservation_ids:
- commission += reservation.commission_amount
-
- # ASSERT
- self.assertEqual(
- folio.commission,
- commission,
- "Folio commission don't math with his reservation commission",
- )
- if folio.agency_id:
- self.assertEqual(
- folio.agency_id, folio.partner_id, "Agency has to be the partner"
- )
-
- def test_compute_folio_priority(self):
- self.create_common_scenario()
- r1 = self.env["pms.reservation"].create(
+ # create rooms
+ self.double1 = self.env["pms.room"].create(
{
- "checkin": fields.date.today(),
- "checkout": fields.date.today() + datetime.timedelta(days=1),
- "room_type_id": self.room_type_double.id,
- "partner_id": self.env.ref("base.res_partner_12").id,
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property_demo.id,
+ "name": "Double 101",
+ "room_type_id": self.demo_room_type_double.id,
+ "capacity": 2,
+ }
+ )
+ self.double2 = self.env["pms.room"].create(
+ {
+ "pms_property_id": self.pms_property_demo.id,
+ "name": "Double 102",
+ "room_type_id": self.demo_room_type_double.id,
+ "capacity": 2,
+ }
+ )
+
+ # TestCases: Sale Channels
+
+ def test_default_agency_commission(self):
+ """
+ Check the total commission of a folio with agency based on the
+ reservation night price and the preconfigured commission in the agency.
+ -------
+ Agency with 15% default commision, folio with one reservation
+ and 3 nights at 20$ by night (60$ total)
+ """
+ # ARRANGE
+ self.create_sale_channel_scenario()
+ commission = (20 + 20 + 20) * 0.15
+
+ # ACT
+ folio1 = self.env["pms.folio"].create(
+ {
+ "agency_id": self.agency1.id,
+ "pms_property_id": self.pms_property1.id,
}
)
- r1.allowed_checkin = False
self.env["pms.reservation"].create(
{
- "folio_id": r1.folio_id.id,
+ "folio_id": folio1.id,
+ "room_type_id": self.room_type_double.id,
+ "reservation_line_ids": [
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today(),
+ "price": 20,
+ },
+ ),
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today() + datetime.timedelta(days=1),
+ "price": 20,
+ },
+ ),
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today() + datetime.timedelta(days=2),
+ "price": 20,
+ },
+ ),
+ ],
+ }
+ )
+ # ASSERT
+ self.assertEqual(
+ commission, folio1.commission, "The folio compute commission is wrong"
+ )
+
+ def test_reservation_agency_without_partner(self):
+ """
+ Check that a reservation / folio created with an agency
+ and without a partner will automatically take the partner.
+ -------
+ Create the folio1 and the reservation1, only set agency_id,
+ and the partner_id should be the agency itself.
+ """
+ # ARRANGE
+ self.create_sale_channel_scenario()
+
+ # ACT
+ folio1 = self.env["pms.folio"].create(
+ {
+ "agency_id": self.agency1.id,
+ "pms_property_id": self.pms_property1.id,
+ }
+ )
+
+ reservation1 = self.env["pms.reservation"].create(
+ {
+ "room_type_id": self.room_type_double.id,
"checkin": fields.date.today(),
"checkout": fields.date.today() + datetime.timedelta(days=1),
- "room_type_id": self.room_type_double.id,
- "partner_id": self.env.ref("base.res_partner_12").id,
- "pms_property_id": self.property.id,
+ "folio_id": folio1.id,
}
)
+ # ASSERT
self.assertEqual(
- r1.priority,
- r1.folio_id.max_reservation_prior,
- "The max. reservation priority on the whole folio is incorrect",
+ reservation1.agency_id, folio1.partner_id, "Agency has to be the partner"
)
+ # TestCases: Priority
+
+ def test_compute_folio_priority(self):
+ """
+ Check the priority of a folio based on its reservations
+ #TODO: Commented test waiting to redefine the priority calculation
+ """
+ # reservation1 = self.env["pms.reservation"].create(
+ # {
+ # "checkin": fields.date.today(),
+ # "checkout": fields.date.today() + datetime.timedelta(days=1),
+ # "room_type_id": self.room_type_double.id,
+ # "partner_id": self.env.ref("base.res_partner_12").id,
+ # "pms_property_id": self.property.id,
+ # }
+ # )
+ # reservation1.allowed_checkin = False
+
+ # self.env["pms.reservation"].create(
+ # {
+ # "folio_id": reservation1.folio_id.id,
+ # "checkin": fields.date.today(),
+ # "checkout": fields.date.today() + datetime.timedelta(days=1),
+ # "room_type_id": self.room_type_double.id,
+ # "partner_id": self.env.ref("base.res_partner_12").id,
+ # "pms_property_id": self.property.id,
+ # }
+ # )
+
+ # self.assertEqual(
+ # reservation1.priority,
+ # reservation1.folio_id.max_reservation_prior,
+ # "The max. reservation priority on the whole folio is incorrect",
+ # )
+
+ # TestCases: Payments
+ @freeze_time("2000-02-02")
def test_full_pay_folio(self):
- # TEST CASE
- # Folio is paid after execute
- #
+ """
+ After making the payment of a folio for the entire amount,
+ check that there is nothing pending.
+ -----
+ We create a reservation (autocalculates the amounts) and
+ then make the payment using the do_payment method of the folio,
+ directly indicating the pending amount on the folio of the newly
+ created reservation
+ """
# ARRANGE
- self.create_common_scenario()
- r_test = self.env["pms.reservation"].create(
+ self.create_configuration_accounting_scenario()
+ reservation1 = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property_demo.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"adults": 2,
"partner_id": self.env.ref("base.res_partner_12").id,
- "room_type_id": self.room_type_double.id,
+ "room_type_id": self.demo_room_type_double.id,
}
)
+
+ # ACTION
self.env["pms.folio"].do_payment(
- self.env["account.journal"].browse(
- r_test.folio_id.pms_property_id._get_payment_methods().ids[0]
+ journal=self.env["account.journal"].browse(
+ reservation1.folio_id.pms_property_id._get_payment_methods().ids[0]
),
- self.env["account.journal"]
- .browse(r_test.folio_id.pms_property_id._get_payment_methods().ids[0])
+ receivable_account=self.env["account.journal"]
+ .browse(reservation1.folio_id.pms_property_id._get_payment_methods().ids[0])
.suspense_account_id,
- self.env.user,
- r_test.folio_id.pending_amount,
- r_test.folio_id,
- partner=r_test.partner_id,
+ user=self.env.user,
+ amount=reservation1.folio_id.pending_amount,
+ folio=reservation1.folio_id,
+ partner=reservation1.partner_id,
date=fields.date.today(),
)
- self.assertFalse(r_test.folio_id.pending_amount)
+ # ASSERT
+ self.assertFalse(
+ reservation1.folio_id.pending_amount,
+ "The pending amount of a folio paid in full has not been zero",
+ )
+
+ @freeze_time("2000-02-02")
def test_partial_pay_folio(self):
- # TEST CASE
- # Folio is partially paid after execute
- #
+ """
+ After making the payment of a folio for the partial amount,
+ We check that the pending amount is the one that corresponds to it.
+ -----
+ We create a reservation (autocalculates the amounts) and
+ then make the payment using the do_payment method of the folio,
+ directly indicating the pending amount on the folio MINUS 1$
+ of the newly created reservation
+ """
# ARRANGE
+ self.create_configuration_accounting_scenario()
left_to_pay = 1
- self.create_common_scenario()
- r_test = self.env["pms.reservation"].create(
+ reservation1 = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property_demo.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"adults": 2,
"partner_id": self.env.ref("base.res_partner_12").id,
- "room_type_id": self.room_type_double.id,
+ "room_type_id": self.demo_room_type_double.id,
}
)
+
+ # ACTION
self.env["pms.folio"].do_payment(
- self.env["account.journal"].browse(
- r_test.folio_id.pms_property_id._get_payment_methods().ids[0]
+ journal=self.env["account.journal"].browse(
+ reservation1.folio_id.pms_property_id._get_payment_methods().ids[0]
),
- self.env["account.journal"]
- .browse(r_test.folio_id.pms_property_id._get_payment_methods().ids[0])
+ receivable_account=self.env["account.journal"]
+ .browse(reservation1.folio_id.pms_property_id._get_payment_methods().ids[0])
.suspense_account_id,
- self.env.user,
- r_test.folio_id.pending_amount - left_to_pay,
- r_test.folio_id,
- partner=r_test.partner_id,
+ user=self.env.user,
+ amount=reservation1.folio_id.pending_amount - left_to_pay,
+ folio=reservation1.folio_id,
+ partner=reservation1.partner_id,
date=fields.date.today(),
)
- self.assertEqual(r_test.folio_id.pending_amount, left_to_pay)
- def test_closure_reason_property(self):
+ # ASSERT
+ self.assertEqual(
+ reservation1.folio_id.pending_amount,
+ left_to_pay,
+ "The pending amount on a partially paid folio it \
+ does not correspond to the amount that it should",
+ )
+
+ # TestCases: Property Consistencies
+
+ def test_folio_closure_reason_consistency_properties(self):
+ """
+ Check the multioproperty consistencia between
+ clousure reasons and folios
+ -------
+ create multiproperty scenario (3 properties in total) and
+ a new clousure reason in pms_property1 and pms_property2, then, create
+ a new folio in property3 and try to set the clousure_reason
+ waiting a error property consistency.
+ """
+ # ARRANGE
self.create_multiproperty_scenario()
cl_reason = self.env["room.closure.reason"].create(
{
"name": "closure_reason_test",
"pms_property_ids": [
- (4, self.property1.id),
- (4, self.property2.id),
+ (4, self.pms_property1.id),
+ (4, self.pms_property2.id),
],
}
)
- with self.assertRaises(UserError):
+ # ACTION & ASSERT
+ with self.assertRaises(
+ UserError,
+ msg="Folio created with clousure_reason_id with properties inconsistence",
+ ):
self.env["pms.folio"].create(
{
- "pms_property_id": self.property3.id,
+ "pms_property_id": self.pms_property3.id,
"closure_reason_id": cl_reason.id,
}
)
-
- def _test_compute_currency(self):
- self.create_common_scenario()
- self.currency1 = self.env["res.currency"].create(
- {
- "name": "currency1",
- "symbol": "C",
- }
- )
- self.pricelist = self.env["product.pricelist"].create(
- {
- "name": "pricelist 1",
- "pms_property_ids": [
- (4, self.property.id),
- ],
- "currency_id": self.currency1.id,
- }
- )
- self.reservation1 = self.env["pms.reservation"].create(
- {
- "pms_property_id": self.property.id,
- "checkin": datetime.datetime.now(),
- "checkout": datetime.datetime.now() + datetime.timedelta(days=1),
- "partner_id": self.env.ref("base.res_partner_12").id,
- "pricelist_id": self.pricelist.id,
- }
- )
- self.assertEqual(
- self.currency1.id,
- self.reservation1.folio_id.currency_id.id,
- "Currency must match",
- )
diff --git a/pms/tests/test_pms_folio_invoice.py b/pms/tests/test_pms_folio_invoice.py
index f2da8e3b6..67754d22b 100644
--- a/pms/tests/test_pms_folio_invoice.py
+++ b/pms/tests/test_pms_folio_invoice.py
@@ -6,10 +6,7 @@ from odoo.tests import common
class TestPmsFolioInvoice(common.SavepointCase):
def setUp(self):
super(TestPmsFolioInvoice, self).setUp()
-
- def create_common_scenario(self):
- # create a room type availability
- # sequences
+ # create a room type availability and sequences
self.folio_sequence = self.env["ir.sequence"].create(
{
"name": "PMS Folio",
@@ -95,7 +92,6 @@ class TestPmsFolioInvoice(common.SavepointCase):
def test_invoice_full_folio(self):
# ARRANGE
- self.create_common_scenario()
r1 = self.env["pms.reservation"].create(
{
"pms_property_id": self.property.id,
@@ -121,7 +117,6 @@ class TestPmsFolioInvoice(common.SavepointCase):
def test_invoice_partial_folio_by_steps(self):
# ARRANGE
- self.create_common_scenario()
r1 = self.env["pms.reservation"].create(
{
"pms_property_id": self.property.id,
@@ -162,7 +157,6 @@ class TestPmsFolioInvoice(common.SavepointCase):
def test_invoice_partial_folio_diferent_partners(self):
# ARRANGE
- self.create_common_scenario()
r1 = self.env["pms.reservation"].create(
{
"pms_property_id": self.property.id,
@@ -208,7 +202,6 @@ class TestPmsFolioInvoice(common.SavepointCase):
def test_invoice_partial_folio_wrong_qtys(self):
# ARRANGE
- self.create_common_scenario()
r1 = self.env["pms.reservation"].create(
{
"pms_property_id": self.property.id,
diff --git a/pms/tests/test_pms_folio_sale_line.py b/pms/tests/test_pms_folio_sale_line.py
index 8e80126e0..500031caa 100644
--- a/pms/tests/test_pms_folio_sale_line.py
+++ b/pms/tests/test_pms_folio_sale_line.py
@@ -1,43 +1,31 @@
import datetime
+from odoo import fields
+
from .common import TestPms
class TestPmsFolioSaleLine(TestPms):
- def create_common_scenario(self):
- # create a room type availability
- self.room_type_availability = self.env["pms.availability.plan"].create(
- {"name": "Availability plan for TEST"}
- )
-
- # create a property
- self.property = self.env["pms.property"].create(
- {
- "name": "MY PMS TEST",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- }
- )
-
- # create room type class
- self.room_type_class = self.env["pms.room.type.class"].create(
- {"name": "Room", "default_code": "ROOM"}
- )
+ def setUp(self):
+ """
+ - common + room_type_avalability_plan
+ """
+ super().setUp()
# create room type
self.room_type_double = self.env["pms.room.type"].create(
{
- "pms_property_ids": [self.property.id],
+ "pms_property_ids": [self.pms_property1.id],
"name": "Double Test",
"default_code": "DBL_Test",
- "class_id": self.room_type_class.id,
+ "class_id": self.room_type_class1.id,
"price": 25,
}
)
# create room
self.room1 = self.env["pms.room"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"name": "Double 101",
"room_type_id": self.room_type_double.id,
"capacity": 2,
@@ -46,21 +34,49 @@ class TestPmsFolioSaleLine(TestPms):
# RESERVATION LINES
def test_comp_fsl_rooms_all_same_group(self):
- # TEST CASE
- # 2-night reservation and same price, discount & cancel_discount for
- # all nights
- # should generate just 1 reservation sale line
-
+ """
+ check the grouping of the reservation lines on the sale line folio
+ when the price, discount match-
+ ------------
+ reservation with 3 nights with the same price,
+ should generate just 1 reservation sale line
+ """
# ARRANGE
expected_sale_lines = 1
- self.create_common_scenario()
# ACT
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
- "checkin": datetime.datetime.now(),
- "checkout": datetime.datetime.now() + datetime.timedelta(days=3),
+ "pms_property_id": self.pms_property1.id,
+ "reservation_line_ids": [
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today(),
+ "price": 20,
+ "discount": 10,
+ },
+ ),
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today() + datetime.timedelta(days=1),
+ "price": 20,
+ "discount": 10,
+ },
+ ),
+ (
+ 0,
+ False,
+ {
+ "date": fields.date.today() + datetime.timedelta(days=2),
+ "price": 20,
+ "discount": 10,
+ },
+ ),
+ ],
"adults": 2,
"room_type_id": self.room_type_double.id,
"partner_id": self.env.ref("base.res_partner_12").id,
@@ -81,10 +97,9 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_sale_lines = 2
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -112,10 +127,9 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_sale_lines = 2
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -143,10 +157,9 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_sale_lines = 2
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -175,10 +188,9 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_sale_lines = 1
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -207,10 +219,9 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation sales line record.
# ARRANGE
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -242,10 +253,9 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation sales line record.
# ARRANGE
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -278,10 +288,9 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation sales line record.
# ARRANGE
- self.create_common_scenario()
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -315,7 +324,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_board_service_sale_lines = 1
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -345,7 +353,7 @@ class TestPmsFolioSaleLine(TestPms):
# ACT
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -375,7 +383,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_board_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -404,7 +411,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -435,7 +442,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_board_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -464,7 +470,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -498,7 +504,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_board_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -527,7 +532,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -561,7 +566,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_board_service_sale_lines = 1
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -590,7 +594,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -623,7 +627,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same board service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -651,7 +654,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -684,7 +687,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same board service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -716,7 +718,7 @@ class TestPmsFolioSaleLine(TestPms):
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -751,7 +753,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same board service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -783,7 +784,7 @@ class TestPmsFolioSaleLine(TestPms):
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -821,7 +822,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_extra_service_sale_lines = 1
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -832,7 +832,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -871,7 +871,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_extra_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -882,7 +881,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -923,7 +922,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_extra_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -934,7 +932,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -976,7 +974,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_extra_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -987,7 +984,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1030,7 +1027,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_extra_service_sale_lines = 1
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1041,7 +1037,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1082,7 +1078,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1093,7 +1088,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1134,7 +1129,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1145,7 +1139,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1187,7 +1181,6 @@ class TestPmsFolioSaleLine(TestPms):
# Should keep the same reservation service sales line record.
# ARRANGE
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1198,7 +1191,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1220,7 +1213,7 @@ class TestPmsFolioSaleLine(TestPms):
# ACT
r_test.service_ids.filtered(
- lambda x: x.id == extra_service
+ lambda x: x.id == extra_service.id
).service_line_ids.price_unit = 50
r_test.service_ids.service_line_ids.flush()
@@ -1242,7 +1235,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_folio_service_sale_lines = 1
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1250,7 +1242,7 @@ class TestPmsFolioSaleLine(TestPms):
)
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
@@ -1289,7 +1281,6 @@ class TestPmsFolioSaleLine(TestPms):
# ARRANGE
expected_folio_service_sale_lines = 2
- self.create_common_scenario()
product_test1 = self.env["product.product"].create(
{
"name": "Test Product 1",
@@ -1303,7 +1294,7 @@ class TestPmsFolioSaleLine(TestPms):
r_test = self.env["pms.reservation"].create(
{
- "pms_property_id": self.property.id,
+ "pms_property_id": self.pms_property1.id,
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
"adults": 2,
diff --git a/pms/tests/test_pms_pricelist.py b/pms/tests/test_pms_pricelist.py
index 7e04d8386..8a1131a7a 100644
--- a/pms/tests/test_pms_pricelist.py
+++ b/pms/tests/test_pms_pricelist.py
@@ -4,80 +4,37 @@ from freezegun import freeze_time
from odoo import fields
from odoo.exceptions import UserError, ValidationError
-from odoo.tests import common, tagged
+from odoo.tests import tagged
+
+from .common import TestPms
@tagged("standard", "nice")
-class TestPmsPricelist(common.SavepointCase):
- def create_common_scenario(self):
- # sequences
- self.folio_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Folio",
- "code": "pms.folio",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.reservation_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Reservation",
- "code": "pms.reservation",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.checkin_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Checkin",
- "code": "pms.checkin.partner",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- # create property
- self.property1 = self.env["pms.property"].create(
- {
- "name": "Property_1",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
- }
- )
-
- self.property2 = self.env["pms.property"].create(
+class TestPmsPricelist(TestPms):
+ def setUp(self):
+ super().setUp()
+ self.pms_property2 = self.env["pms.property"].create(
{
"name": "Property_2",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
}
)
- self.property3 = self.env["pms.property"].create(
+ self.pms_property3 = self.env["pms.property"].create(
{
"name": "Property_3",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
}
)
- self.room_type_class = self.env["pms.room.type.class"].create(
- {"name": "Room Class", "default_code": "ROOM"}
- )
- self.room_type = self.env["pms.room.type"].create(
+ self.room_type1 = self.env["pms.room.type"].create(
{
- "pms_property_ids": [self.property1.id, self.property2.id],
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"name": "Single",
"default_code": "SIN",
- "class_id": self.room_type_class.id,
+ "class_id": self.room_type_class1.id,
"list_price": 30,
}
)
@@ -85,135 +42,83 @@ class TestPmsPricelist(common.SavepointCase):
# pms.room
self.room1 = self.env["pms.room"].create(
{
- "pms_property_id": self.property1.id,
+ "pms_property_id": self.pms_property1.id,
"name": "Single 101",
- "room_type_id": self.room_type.id,
+ "room_type_id": self.room_type1.id,
"capacity": 2,
}
)
- self.pricelist = self.env["product.pricelist"].create(
+ self.pricelist2 = self.env["product.pricelist"].create(
{
- "name": "pricelist_1",
- "pms_property_ids": [self.property1.id, self.property2.id],
+ "name": "pricelist_2",
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
}
)
# product.product 1
- self.test_service_breakfast = self.env["product.product"].create(
- {"name": "Test Breakfast"}
- )
+ self.product1 = self.env["product.product"].create({"name": "Test Breakfast"})
# pms.board.service
- self.test_board_service_only_breakfast = self.env["pms.board.service"].create(
+ self.board_service1 = self.env["pms.board.service"].create(
{
"name": "Test Only Breakfast",
"default_code": "CB1",
}
)
# pms.board.service.line
- self.board_service_line_single_1 = self.env["pms.board.service.line"].create(
+ self.board_service_line1 = self.env["pms.board.service.line"].create(
{
- "product_id": self.test_service_breakfast.id,
- "pms_board_service_id": self.test_board_service_only_breakfast.id,
+ "product_id": self.product1.id,
+ "pms_board_service_id": self.board_service1.id,
}
)
# pms.board.service.room.type
- self.test_board_service_single = self.env["pms.board.service.room.type"].create(
+ self.board_service_room_type1 = self.env["pms.board.service.room.type"].create(
{
- "pms_room_type_id": self.room_type.id,
- "pms_board_service_id": self.test_board_service_only_breakfast.id,
+ "pms_room_type_id": self.room_type1.id,
+ "pms_board_service_id": self.board_service1.id,
}
)
self.partner1 = self.env["res.partner"].create({"name": "Carles"})
- def test_advanced_pricelist_exists(self):
-
+ def test_inconsistency_property_pricelist_item(self):
+ """
+ Check a pricelist item and its pricelist are inconsistent with the property.
+ Create a pricelist item that belongs to a property and check if
+ a pricelist that belongs to a diferent one, cannot be created.
+ """
# ARRANGE
- key = "product.product_pricelist_setting"
- value = "advanced"
-
- # ACT
- found_value = self.env["ir.config_parameter"].sudo().get_param(key)
-
- # ASSERT
- self.assertEqual(found_value, value, "Parameter doesn't exist")
-
- def test_product_pricelist_setting_modified(self):
-
- # ARRANGE
- key = "product.product_pricelist_setting"
- value = "basic"
-
- # ACT & ASSERT
- with self.assertRaises(ValidationError), self.cr.savepoint():
- self.env["ir.config_parameter"].set_param(key, value)
-
- def test_product_pricelist_setting_unlink(self):
-
- # ARRANGE
- key = "product.product_pricelist_setting"
- value = "advanced"
-
- # ACT & ASSERT
- with self.assertRaises(ValidationError), self.cr.savepoint():
- self.env["ir.config_parameter"].search(
- [("key", "=", key), ("value", "=", value)]
- ).unlink()
-
- def test_check_property_pricelist(self):
- # ARRANGE
- self.create_common_scenario()
# ACT & ASSERT
with self.assertRaises(UserError):
self.item1 = self.env["product.pricelist.item"].create(
{
"name": "item_1",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"date_start": datetime.datetime.today(),
"date_end": datetime.datetime.today() + datetime.timedelta(days=1),
"fixed_price": 40.0,
- "pricelist_id": self.pricelist.id,
- "pms_property_ids": [self.property3.id],
+ "pricelist_id": self.pricelist2.id,
+ "pms_property_ids": [self.pms_property3.id],
}
)
- def test_check_property_room_type(self):
+ def test_inconsistency_cancelation_rule_property(self):
+ """
+ Check a cancelation rule and its pricelist are inconsistent with the property.
+ Create a cancelation rule that belongs to a two properties and check if
+ a pricelist that belongs to a diferent properties, cannot be created.
+ """
# ARRANGE
- self.create_common_scenario()
- # ACT
- self.pricelist1 = self.env["product.pricelist"].create(
- {
- "name": "pricelist_1",
- "pms_property_ids": [self.property1.id, self.property3.id],
- }
- )
- # ASSERT
- with self.assertRaises(UserError):
- self.item1 = self.env["product.pricelist.item"].create(
- {
- "name": "item_1",
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.today(),
- "date_end": datetime.datetime.today() + datetime.timedelta(days=1),
- "fixed_price": 40.0,
- "pricelist_id": self.pricelist1.id,
- "pms_property_ids": [self.property3.id],
- }
- )
- def test_cancelation_rule_property(self):
- # ARRANGE
- self.create_common_scenario()
Pricelist = self.env["product.pricelist"]
# ACT
self.cancelation_rule = self.env["pms.cancelation.rule"].create(
{
"name": "Cancelation Rule Test",
- "pms_property_ids": [self.property1.id, self.property3.id],
+ "pms_property_ids": [self.pms_property1.id, self.pms_property3.id],
}
)
# ASSERT
@@ -221,39 +126,42 @@ class TestPmsPricelist(common.SavepointCase):
Pricelist.create(
{
"name": "Pricelist Test",
- "pms_property_ids": [self.property1.id, self.property2.id],
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"cancelation_rule_id": self.cancelation_rule.id,
}
)
- def test_availability_plan_property_integrity(self):
- self.create_common_scenario()
+ def test_inconsistency_availability_plan_property(self):
+ """
+ Check a availability plan and its pricelist are inconsistent with the property.
+ Create a availability plan that belongs to a two properties and check if
+ a pricelist that belongs to a diferent properties, cannot be created.
+ """
self.availability_plan = self.env["pms.availability.plan"].create(
- {"name": "Availability Plan", "pms_property_ids": [self.property1.id]}
+ {"name": "Availability Plan", "pms_property_ids": [self.pms_property1.id]}
)
with self.assertRaises(UserError):
self.env["product.pricelist"].create(
{
"name": "Pricelist",
- "pms_property_ids": [self.property2.id],
+ "pms_property_ids": [self.pms_property2.id],
"availability_plan_id": self.availability_plan.id,
}
)
- # board services pricelist items
+ @freeze_time("2000-01-01")
def test_board_service_pricelist_item_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on board services at SALE date.
- # The reservation created take into account the board service
- # pricelist item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on board services at SALE date.
+ The reservation created take into account the board service
+ pricelist item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today()
date_to = fields.date.today()
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -262,10 +170,10 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
- "board_service_room_type_id": self.test_board_service_single.id,
+ "product_id": self.product1.id,
+ "board_service_room_type_id": self.board_service_room_type1.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -275,9 +183,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "board_service_room_id": self.test_board_service_single.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "board_service_room_id": self.board_service_room_type1.id,
}
)
# ASSERT
@@ -288,19 +196,19 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_board_service_pricelist_item_not_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on board services at SALE date.
- # The reservation created DONT take into account the board service pricelist
- # item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on board services at SALE date.
+ The reservation created DONT take into account the board service pricelist
+ item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -309,10 +217,10 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
- "board_service_room_type_id": self.test_board_service_single.id,
+ "product_id": self.product1.id,
+ "board_service_room_type_id": self.board_service_room_type1.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -322,9 +230,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "board_service_room_id": self.test_board_service_single.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "board_service_room_id": self.board_service_room_type1.id,
}
)
# ASSERT
@@ -335,28 +243,28 @@ class TestPmsPricelist(common.SavepointCase):
" item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_board_service_pricelist_item_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on board services
- # at CONSUMPTION date.
- # The reservation created take into account the board service
- # pricelist item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on board services
+ at CONSUMPTION date.
+ The reservation created take into account the board service
+ pricelist item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start_consumption": date_from,
"date_end_consumption": date_to,
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
- "board_service_room_type_id": self.test_board_service_single.id,
+ "product_id": self.product1.id,
+ "board_service_room_type_id": self.board_service_room_type1.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -366,9 +274,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now() + datetime.timedelta(days=1),
"checkout": datetime.datetime.now() + datetime.timedelta(days=2),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "board_service_room_id": self.test_board_service_single.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "board_service_room_id": self.board_service_room_type1.id,
}
)
# ASSERT
@@ -379,20 +287,20 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
+ @freeze_time("2000-01-01")
def test_board_service_pricelist_item_not_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on board services
- # at CONSUMPTION date.
- # The reservation created DONT take into account the board service
- # pricelist item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on board services
+ at CONSUMPTION date.
+ The reservation created DONT take into account the board service
+ pricelist item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=2)
date_to = fields.date.today() + datetime.timedelta(days=2)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -401,10 +309,10 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
- "board_service_room_type_id": self.test_board_service_single.id,
+ "product_id": self.product1.id,
+ "board_service_room_type_id": self.board_service_room_type1.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -414,9 +322,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "board_service_room_id": self.test_board_service_single.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "board_service_room_id": self.board_service_room_type1.id,
}
)
# ASSERT
@@ -427,21 +335,20 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
- # room types pricelist items
+ @freeze_time("2000-01-01")
def test_room_type_pricelist_item_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on room types
- # at SALE date.
- # The reservation created take into account the room type
- # pricelist item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on room types
+ at SALE date.
+ The reservation created take into account the room type
+ pricelist item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today()
date_to = fields.date.today()
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -450,9 +357,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -462,8 +369,8 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
}
)
# ASSERT
@@ -474,20 +381,20 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_room_type_pricelist_item_not_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on room types
- # at SALE date.
- # The reservation created DONT take into account the room type
- # pricelist item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on room types
+ at SALE date.
+ The reservation created DONT take into account the room type
+ pricelist item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -496,9 +403,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -508,8 +415,8 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
}
)
# ASSERT
@@ -520,27 +427,27 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_room_type_pricelist_item_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on room types
- # at CONSUMPTION date.
- # The reservation created take into account the room type
- # pricelist item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on room types
+ at CONSUMPTION date.
+ The reservation created take into account the room type
+ pricelist item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start_consumption": date_from,
"date_end_consumption": date_to,
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -550,8 +457,8 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now() + datetime.timedelta(days=1),
"checkout": datetime.datetime.now() + datetime.timedelta(days=2),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
}
)
# ASSERT
@@ -562,20 +469,20 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
+ @freeze_time("2000-01-01")
def test_room_type_pricelist_item_not_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on room types
- # at CONSUMPTION date.
- # The reservation created DONT take into account the room type
- # pricelist item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on room types
+ at CONSUMPTION date.
+ The reservation created DONT take into account the room type
+ pricelist item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=2)
date_to = fields.date.today() + datetime.timedelta(days=2)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -584,9 +491,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -596,8 +503,8 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
}
)
# ASSERT
@@ -608,20 +515,19 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
- # services pricelist items
+ @freeze_time("2000-01-01")
def test_service_pricelist_item_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on services at SALE date.
- # The reservation created take into account the service
- # pricelist item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on services at SALE date.
+ The reservation created take into account the service
+ pricelist item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today()
date_to = fields.date.today()
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -630,9 +536,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
+ "product_id": self.product1.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -642,9 +548,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "service_ids": [(0, 0, {"product_id": self.test_service_breakfast.id})],
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "service_ids": [(0, 0, {"product_id": self.product1.id})],
}
)
# ASSERT
@@ -655,19 +561,19 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_service_pricelist_item_not_apply_sale_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on services at SALE date.
- # The reservation created DONT take into account the service pricelist
- # item created previously according to the SALE date.
-
+ """
+ Pricelist item is created to apply on services at SALE date.
+ The reservation created DONT take into account the service pricelist
+ item created previously according to the SALE date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -676,9 +582,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
+ "product_id": self.product1.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -688,9 +594,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "service_ids": [(0, 0, {"product_id": self.test_service_breakfast.id})],
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "service_ids": [(0, 0, {"product_id": self.product1.id})],
}
)
# ASSERT
@@ -701,26 +607,26 @@ class TestPmsPricelist(common.SavepointCase):
" item created previously according to the SALE date.",
)
+ @freeze_time("2000-01-01")
def test_service_pricelist_item_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on services at CONSUMPTION date.
- # The reservation created take into account the service
- # pricelist item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on services at CONSUMPTION date.
+ The reservation created take into account the service
+ pricelist item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=1)
date_to = fields.date.today() + datetime.timedelta(days=1)
expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start_consumption": date_from,
"date_end_consumption": date_to,
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
+ "product_id": self.product1.id,
"fixed_price": expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -730,9 +636,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now() + datetime.timedelta(days=1),
"checkout": datetime.datetime.now() + datetime.timedelta(days=2),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "service_ids": [(0, 0, {"product_id": self.test_service_breakfast.id})],
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "service_ids": [(0, 0, {"product_id": self.product1.id})],
}
)
# ASSERT
@@ -743,19 +649,19 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
+ @freeze_time("2000-01-01")
def test_service_pricelist_item_not_apply_consumption_dates(self):
- # TEST CASE
- # Pricelist item is created to apply on services at CONSUMPTION date.
- # The reservation created DONT take into account the service pricelist
- # item created previously according to the CONSUMPTION date.
-
+ """
+ Pricelist item is created to apply on services at CONSUMPTION date.
+ The reservation created DONT take into account the service pricelist
+ item created previously according to the CONSUMPTION date.
+ """
# ARRANGE
- self.create_common_scenario()
date_from = fields.date.today() + datetime.timedelta(days=2)
date_to = fields.date.today() + datetime.timedelta(days=2)
not_expected_price = 1000.0
vals = {
- "pricelist_id": self.pricelist.id,
+ "pricelist_id": self.pricelist2.id,
"date_start": datetime.datetime.combine(
date_from, datetime.datetime.min.time()
),
@@ -764,9 +670,9 @@ class TestPmsPricelist(common.SavepointCase):
),
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.test_service_breakfast.id,
+ "product_id": self.product1.id,
"fixed_price": not_expected_price,
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
}
self.env["product.pricelist.item"].create(vals)
# ACT
@@ -776,9 +682,9 @@ class TestPmsPricelist(common.SavepointCase):
"checkin": datetime.datetime.now(),
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
"preferred_room_id": self.room1.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- "service_ids": [(0, 0, {"product_id": self.test_service_breakfast.id})],
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist2.id,
+ "service_ids": [(0, 0, {"product_id": self.product1.id})],
}
)
# ASSERT
@@ -790,12 +696,30 @@ class TestPmsPricelist(common.SavepointCase):
)
@freeze_time("2000-01-01")
- def test_pricelist_daily_failed(self):
- self.create_common_scenario()
+ def test_inconsistencies_pricelist_daily(self):
+ """
+ Test cases to verify that a daily pricelist cannot be created because:
+ (Test case1): item has two properties and a items daily pricelist only
+ can has a one property.
+ (Test case2): item has all properties(pms_property_ids = False indicates
+ all properties)and a items daily pricelist only can has a one property.
+ (Test case3): item compute_price is 'percentage' and only can be 'fixed'
+ for items daily pricelist.
+ (Test case4): item compute_price is 'percentage' and has two properties
+ but compute_price can only be fixed and can only have one
+ property for items daily pricelist.
+ (Test case5): item compute_price is 'percentage' and has all properties
+ (pms_property_ids = False indicates all properties)but
+ compute_pricecan only be fixed and can only have one property for
+ items daily pricelist.
+ (Test case6): The difference of days between date_start_consumption and
+ date_end_consumption is three and the items of a daily pricelist
+ can only be one.
+ """
test_cases = [
{
"compute_price": "fixed",
- "pms_property_ids": [self.property1.id, self.property2.id],
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
@@ -809,14 +733,14 @@ class TestPmsPricelist(common.SavepointCase):
},
{
"compute_price": "percentage",
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
},
{
"compute_price": "percentage",
- "pms_property_ids": [self.property1.id, self.property2.id],
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
@@ -830,7 +754,7 @@ class TestPmsPricelist(common.SavepointCase):
},
{
"compute_price": "fixed",
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=3),
@@ -839,14 +763,19 @@ class TestPmsPricelist(common.SavepointCase):
for tc in test_cases:
with self.subTest(k=tc):
- with self.assertRaises(ValidationError):
- self.room_type.pms_property_ids = tc["pms_property_ids"]
+ with self.assertRaises(
+ ValidationError,
+ msg="Item only can has one property, the compute price only can"
+ "be fixed and the difference between date_start_consumption"
+ "and date_end_consumption only can be 1",
+ ):
+ self.room_type1.pms_property_ids = tc["pms_property_ids"]
item = self.env["product.pricelist.item"].create(
{
"pms_property_ids": tc["pms_property_ids"],
"compute_price": tc["compute_price"],
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"date_start_consumption": tc["date_start_consumption"],
"date_end_consumption": tc["date_end_consumption"],
}
@@ -861,15 +790,19 @@ class TestPmsPricelist(common.SavepointCase):
)
@freeze_time("2020-01-01")
- def test_pricelist_daily(self):
- self.create_common_scenario()
- self.room_type.pms_property_ids = (self.property1.id,)
+ def test_consistency_pricelist_daily(self):
+ """
+ Test to verify that a daily pricelist is created.
+ Create a pricelist item with a property, the value of compute_price is
+ fixed and date_start_consumption date_end_consumption has the same value
+ """
+ self.room_type1.pms_property_ids = (self.pms_property1.id,)
item = self.env["product.pricelist.item"].create(
{
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
"compute_price": "fixed",
"applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
+ "product_id": self.room_type1.product_id.id,
"date_start_consumption": datetime.date.today(),
"date_end_consumption": datetime.date.today(),
}
@@ -878,8 +811,496 @@ class TestPmsPricelist(common.SavepointCase):
{
"name": "Pricelist test",
"pricelist_type": "daily",
- "pms_property_ids": [self.property1.id],
+ "pms_property_ids": [self.pms_property1.id],
"item_ids": [item.id],
}
)
self.assertTrue(self.pricelist_test, "Pricelist not created.")
+
+ @freeze_time("2000-01-01")
+ def test_simple_price_without_items(self):
+ """
+ Test case for no items applied in a reservation.
+ """
+
+ # ARRANGE
+ self.room_type = self.env["pms.room.type"].create(
+ {
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
+ "name": "Single",
+ "default_code": "S",
+ "class_id": self.room_type_class1.id,
+ "list_price": 30,
+ }
+ )
+
+ self.room = self.env["pms.room"].create(
+ {
+ "pms_property_id": self.pms_property1.id,
+ "name": "Single 1",
+ "room_type_id": self.room_type.id,
+ }
+ )
+ reservation = self.env["pms.reservation"].create(
+ {
+ "checkin": datetime.datetime.today(),
+ "checkout": datetime.datetime.today() + datetime.timedelta(days=3),
+ "preferred_room_id": self.room.id,
+ "pms_property_id": self.pms_property1.id,
+ "partner_id": self.partner1.id,
+ }
+ )
+ # ACT
+ n_days = (reservation.checkout - reservation.checkin).days
+ expected_price = self.room.room_type_id.list_price * n_days
+
+ # ASSERT
+ self.assertEqual(
+ expected_price, reservation.price_subtotal, "The price is not as expected"
+ )
+
+ @freeze_time("2022-01-01")
+ def test_items_sort(self):
+ """
+ Test cases to verify the order for each field considered individually
+ Test cases to prioritize fields over other fields:
+ 1. applied_on
+ 2. date
+ 3. date consumption
+ 4. num. properties
+ 5. id
+ - tie
+ - no [date_start|date_end|date_start_consumption|date_end_consumption]
+ """
+ # ARRANGE
+ self.product_category = self.env["product.category"].create(
+ {"name": "Category1"}
+ )
+ self.product_template = self.env["product.template"].create(
+ {"name": "Template1"}
+ )
+ self.room_type = self.env["pms.room.type"].create(
+ {
+ "pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
+ "name": "Single",
+ "default_code": "SGL",
+ "class_id": self.room_type_class1.id,
+ "list_price": 30,
+ }
+ )
+
+ self.room = self.env["pms.room"].create(
+ {
+ "pms_property_id": self.pms_property1.id,
+ "name": "101",
+ "room_type_id": self.room_type.id,
+ }
+ )
+ properties = self.room_type.product_id.pms_property_ids.ids
+ test_cases = [
+ {
+ "name": "sorting applied_on",
+ "expected_price": 50 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "2_product_category",
+ "categ_id": self.product_category.id,
+ "fixed_price": 60.0,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "1_product",
+ "product_id": self.room_type.product_id.id,
+ "product_tmpl_id": self.product_template.id,
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "sorting SALE date min range",
+ "expected_price": 50.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=2),
+ "fixed_price": 60.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=1),
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "sorting CONSUMPTION date min range",
+ "expected_price": 40.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=6),
+ "fixed_price": 60.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=10),
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "sorting num. properties",
+ "expected_price": 50.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "fixed_price": 60.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "pms_property_ids": [self.pms_property1.id],
+ "fixed_price": 50.0,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "pms_property_ids": [
+ self.pms_property1.id,
+ self.pms_property2.id,
+ ],
+ "fixed_price": 40.0,
+ },
+ ],
+ },
+ {
+ "name": "sorting by item id",
+ "expected_price": 40.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "fixed_price": 60.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "prioritize applied_on over SALE date",
+ "expected_price": 60.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=2),
+ "fixed_price": 60.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "product_id": self.room_type.product_id.id,
+ "product_tmpl_id": self.product_template.id,
+ "applied_on": "1_product",
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=1),
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "prioritize SALE date over CONSUMPTION date",
+ "expected_price": 120.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=10),
+ "fixed_price": 120.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "fixed_price": 50.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "prioritize CONSUMPTION date over min. num. properties",
+ "expected_price": 50.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "fixed_price": 120.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "pms_property_ids": [
+ self.pms_property1.id,
+ self.pms_property2.id,
+ ],
+ "fixed_price": 50.0,
+ },
+ ],
+ },
+ {
+ "name": "prioritize min. num. properties over item id",
+ "expected_price": 50.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "fixed_price": 120.0,
+ "pms_property_ids": properties,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "pms_property_ids": [
+ self.pms_property1.id,
+ self.pms_property2.id,
+ ],
+ "fixed_price": 50.0,
+ },
+ ],
+ },
+ {
+ "name": "tie => order by item id",
+ "expected_price": 50.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "pms_property_ids": [
+ self.pms_property1.id,
+ self.pms_property2.id,
+ ],
+ "fixed_price": 120.0,
+ },
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "date_start": datetime.datetime.now(),
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "pms_property_ids": [
+ self.pms_property1.id,
+ self.pms_property2.id,
+ ],
+ "fixed_price": 50.0,
+ },
+ ],
+ },
+ {
+ "name": "no SALE DATE START",
+ "expected_price": 40.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_end": datetime.datetime.now()
+ + datetime.timedelta(days=1),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "no SALE DATE END",
+ "expected_price": 40.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start": datetime.datetime.now(),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "no consumption DATE START",
+ "expected_price": 40.0 + self.room_type.list_price * 2,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_end_consumption": datetime.datetime.now(),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "no consumption DATE END",
+ "expected_price": 40.0 * 3,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ {
+ "name": "only applied consumption in one night",
+ "expected_price": 40.0 + self.room_type.list_price * 2,
+ "items": [
+ {
+ "pricelist_id": self.pricelist1.id,
+ "applied_on": "0_product_variant",
+ "product_id": self.room_type.product_id.id,
+ "date_start_consumption": datetime.datetime.now(),
+ "date_end_consumption": datetime.datetime.now(),
+ "fixed_price": 40.0,
+ "pms_property_ids": properties,
+ },
+ ],
+ },
+ ]
+
+ for tc in test_cases:
+ with self.subTest(k=tc):
+
+ # ARRANGE
+ items = []
+ for item in tc["items"]:
+ item = self.env["product.pricelist.item"].create(item)
+ items.append(item.id)
+
+ # ACT
+ reservation = self.env["pms.reservation"].create(
+ {
+ "partner_id": self.partner1.id,
+ "checkin": datetime.datetime.now(),
+ "checkout": datetime.datetime.now()
+ + datetime.timedelta(days=3),
+ "preferred_room_id": self.room.id,
+ "pms_property_id": self.pms_property1.id,
+ "pricelist_id": self.pricelist1.id,
+ }
+ )
+ reservation_price = reservation.price_subtotal
+ self.env["pms.reservation"].browse(reservation.id).unlink()
+ self.env["product.pricelist.item"].browse(items).unlink()
+
+ # ASSERT
+ self.assertEqual(tc["expected_price"], reservation_price, tc["name"])
diff --git a/pms/tests/test_pms_pricelist_priority.py b/pms/tests/test_pms_pricelist_priority.py
deleted file mode 100644
index 94011c18b..000000000
--- a/pms/tests/test_pms_pricelist_priority.py
+++ /dev/null
@@ -1,541 +0,0 @@
-import datetime
-
-from freezegun import freeze_time
-
-from odoo.tests import common
-
-
-class TestPmsPricelistRules(common.SavepointCase):
- def create_common_scenario(self):
- self.product_template = self.env["product.template"].create(
- {"name": "Template1"}
- )
- self.product_category = self.env["product.category"].create(
- {"name": "Category1"}
- )
-
- self.availability_plan1 = self.env["pms.availability.plan"].create(
- {"name": "Availability 1"}
- )
-
- self.availability_plan2 = self.env["pms.availability.plan"].create(
- {"name": "Availability"}
- )
- # sequences
- self.folio_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Folio",
- "code": "pms.folio",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.reservation_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Reservation",
- "code": "pms.reservation",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.checkin_sequence = self.env["ir.sequence"].create(
- {
- "name": "PMS Checkin",
- "code": "pms.checkin.partner",
- "padding": 4,
- "company_id": self.env.ref("base.main_company").id,
- }
- )
- self.property1 = self.env["pms.property"].create(
- {
- "name": "Property_1",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
- }
- )
-
- self.property2 = self.env["pms.property"].create(
- {
- "name": "Property_2",
- "company_id": self.env.ref("base.main_company").id,
- "default_pricelist_id": self.env.ref("product.list0").id,
- "folio_sequence_id": self.folio_sequence.id,
- "reservation_sequence_id": self.reservation_sequence.id,
- "checkin_sequence_id": self.checkin_sequence.id,
- }
- )
-
- self.room_type_class = self.env["pms.room.type.class"].create(
- {"name": "Room Class", "default_code": "ROOM"}
- )
-
- self.room_type = self.env["pms.room.type"].create(
- {
- "pms_property_ids": [self.property1.id, self.property2.id],
- "name": "Single",
- "default_code": "SIN",
- "class_id": self.room_type_class.id,
- "list_price": 30,
- }
- )
-
- self.room = self.env["pms.room"].create(
- {
- "pms_property_id": self.property1.id,
- "name": "Single 101",
- "room_type_id": self.room_type.id,
- }
- )
-
- self.room2 = self.env["pms.room"].create(
- {
- "pms_property_id": self.property2.id,
- "name": "Single 102",
- "room_type_id": self.room_type.id,
- }
- )
-
- self.pricelist = self.env["product.pricelist"].create(
- {
- "name": "pricelist_1",
- }
- )
-
- self.partner1 = self.env["res.partner"].create({"name": "Carles"})
-
- @freeze_time("2000-01-01")
- def test_simple_price_without_items(self):
- # TEST CASE : no items applied
-
- # ARRANGE
- self.create_common_scenario()
-
- reservation = self.env["pms.reservation"].create(
- {
- "checkin": datetime.datetime.today(),
- "checkout": datetime.datetime.today() + datetime.timedelta(days=3),
- "preferred_room_id": self.room.id,
- "pms_property_id": self.property1.id,
- "partner_id": self.partner1.id,
- }
- )
- # ACT
- n_days = (reservation.checkout - reservation.checkin).days
- expected_price = self.room.room_type_id.list_price * n_days
-
- # ASSERT
- self.assertEqual(
- expected_price, reservation.price_subtotal, "The price is not as expected"
- )
-
- @freeze_time("2022-01-01")
- def test_items_sort(self):
-
- # ARRANGE
- self.create_common_scenario()
-
- # - test cases to verify the order for each field considered individually
- # - test cases to prioritize fields over other fields:
- # 1. applied_on
- # 2. date
- # 3. date consumption
- # 4. num. properties
- # 5. id
- # - tie
- # - no [date_start|date_end|date_start_consumption|date_end_consumption]
- properties = self.room_type.product_id.pms_property_ids.ids
- test_cases = [
- {
- "name": "sorting applied_on",
- "expected_price": 50 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "2_product_category",
- "categ_id": self.product_category.id,
- "fixed_price": 60.0,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "1_product",
- "product_id": self.room_type.product_id.id,
- "product_tmpl_id": self.product_template.id,
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "sorting SALE date min range",
- "expected_price": 50.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=2),
- "fixed_price": 60.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=1),
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "sorting CONSUMPTION date min range",
- "expected_price": 40.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=6),
- "fixed_price": 60.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=10),
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "sorting num. properties",
- "expected_price": 50.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "fixed_price": 60.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "pms_property_ids": [self.property1.id],
- "fixed_price": 50.0,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "pms_property_ids": [self.property1.id, self.property2.id],
- "fixed_price": 40.0,
- },
- ],
- },
- {
- "name": "sorting by item id",
- "expected_price": 40.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "fixed_price": 60.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "prioritize applied_on over SALE date",
- "expected_price": 60.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=2),
- "fixed_price": 60.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "product_id": self.room_type.product_id.id,
- "product_tmpl_id": self.product_template.id,
- "applied_on": "1_product",
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=1),
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "prioritize SALE date over CONSUMPTION date",
- "expected_price": 120.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=10),
- "fixed_price": 120.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "fixed_price": 50.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "prioritize CONSUMPTION date over min. num. properties",
- "expected_price": 50.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "fixed_price": 120.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "pms_property_ids": [self.property1.id, self.property2.id],
- "fixed_price": 50.0,
- },
- ],
- },
- {
- "name": "prioritize min. num. properties over item id",
- "expected_price": 50.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "fixed_price": 120.0,
- "pms_property_ids": properties,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "pms_property_ids": [self.property1.id, self.property2.id],
- "fixed_price": 50.0,
- },
- ],
- },
- {
- "name": "tie => order by item id",
- "expected_price": 50.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "pms_property_ids": [self.property1.id, self.property2.id],
- "fixed_price": 120.0,
- },
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "date_start": datetime.datetime.now(),
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "pms_property_ids": [self.property1.id, self.property2.id],
- "fixed_price": 50.0,
- },
- ],
- },
- {
- "name": "no SALE DATE START",
- "expected_price": 40.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_end": datetime.datetime.now()
- + datetime.timedelta(days=1),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "no SALE DATE END",
- "expected_price": 40.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start": datetime.datetime.now(),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "no consumption DATE START",
- "expected_price": 40.0 + self.room_type.list_price * 2,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_end_consumption": datetime.datetime.now(),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "no consumption DATE END",
- "expected_price": 40.0 * 3,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- {
- "name": "only applied consumption in one night",
- "expected_price": 40.0 + self.room_type.list_price * 2,
- "items": [
- {
- "pricelist_id": self.pricelist.id,
- "applied_on": "0_product_variant",
- "product_id": self.room_type.product_id.id,
- "date_start_consumption": datetime.datetime.now(),
- "date_end_consumption": datetime.datetime.now(),
- "fixed_price": 40.0,
- "pms_property_ids": properties,
- },
- ],
- },
- ]
-
- for tc in test_cases:
- with self.subTest(k=tc):
-
- # ARRANGE
- items = []
- for item in tc["items"]:
- item = self.env["product.pricelist.item"].create(item)
- items.append(item.id)
-
- # ACT
- reservation = self.env["pms.reservation"].create(
- {
- "partner_id": self.partner1.id,
- "checkin": datetime.datetime.now(),
- "checkout": datetime.datetime.now()
- + datetime.timedelta(days=3),
- "preferred_room_id": self.room.id,
- "pms_property_id": self.property1.id,
- "pricelist_id": self.pricelist.id,
- }
- )
- reservation_price = reservation.price_subtotal
- self.env["pms.reservation"].browse(reservation.id).unlink()
- self.env["product.pricelist.item"].browse(items).unlink()
-
- # ASSERT
- self.assertEqual(tc["expected_price"], reservation_price, tc["name"])
diff --git a/pms/tests/test_pms_pricelist_settings.py b/pms/tests/test_pms_pricelist_settings.py
new file mode 100644
index 000000000..7b04ebc96
--- /dev/null
+++ b/pms/tests/test_pms_pricelist_settings.py
@@ -0,0 +1,55 @@
+from odoo.exceptions import ValidationError
+
+from .common import TestPms
+
+
+class TestPmsPricelistSettings(TestPms):
+ def test_advanced_pricelist_exists(self):
+ """
+ Check if value of Pricelist parameter in sales settings is Advanced Price Rules.
+ Find the value of Pricelist parameter
+ with the key product.product_pricelist_setting and check if is equal to "advanced".
+ """
+ # ARRANGE
+ key = "product.product_pricelist_setting"
+ value = "advanced"
+
+ # ACT
+ found_value = self.env["ir.config_parameter"].sudo().get_param(key)
+
+ # ASSERT
+ self.assertEqual(
+ found_value, value, "Parameter of Pricelist in setting is not 'advanced'"
+ )
+
+ def test_product_pricelist_setting_not_modified(self):
+ """
+ Check that Pricelist parameter 'advanced' cannot be modified.
+ Set the value of product.product_pricelist_setting to 'basic'
+ but is not possible because this only can be 'advanced'.
+ """
+ # ARRANGE
+ key = "product.product_pricelist_setting"
+ value = "basic"
+
+ # ACT & ASSERT
+ with self.assertRaises(
+ ValidationError, msg="The Pricelist parameter 'advanced' was modified."
+ ):
+ self.env["ir.config_parameter"].set_param(key, value)
+
+ def test_product_pricelist_setting_not_unlink(self):
+ """
+ Check that Pricelist parameter 'advanced' cannot be unlink.
+ Try to unlink the parameter product_pricelist with value 'advanced'
+ but this should be impossible.
+ """
+ # ARRANGE
+ key = "product.product_pricelist_setting"
+ value = "advanced"
+
+ # ACT & ASSERT
+ with self.assertRaises(ValidationError), self.cr.savepoint():
+ self.env["ir.config_parameter"].search(
+ [("key", "=", key), ("value", "=", value)]
+ ).unlink()
diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py
index f9e63fe5a..4aa2fb72c 100644
--- a/pms/tests/test_pms_reservation.py
+++ b/pms/tests/test_pms_reservation.py
@@ -153,6 +153,84 @@ class TestPmsReservations(common.SavepointCase):
}
)
+ @freeze_time("1980-11-01")
+ def test_reservation_dates_not_consecutive(self):
+ """
+ Check the constrain if not consecutive dates
+ ----------------
+ Create correct reservation set 3 reservation lines consecutives (nights)
+ """
+ # ARRANGE
+ self.create_common_scenario()
+ customer = self.env.ref("base.res_partner_12")
+ today = fields.date.today()
+ tomorrow = fields.date.today() + datetime.timedelta(days=1)
+ three_days_later = fields.date.today() + datetime.timedelta(days=3)
+
+ # ACT & ASSERT
+ with self.assertRaises(
+ ValidationError,
+ msg="Error, it has been allowed to create a reservation with non-consecutive days",
+ ):
+ self.env["pms.reservation"].create(
+ {
+ "room_type_id": self.room_type_double.id,
+ "partner_id": customer.id,
+ "pms_property_id": self.property.id,
+ "reservation_line_ids": [
+ (0, False, {"date": today}),
+ (0, False, {"date": tomorrow}),
+ (0, False, {"date": three_days_later}),
+ ],
+ }
+ )
+
+ @freeze_time("1980-11-01")
+ def test_reservation_dates_compute_checkin_out(self):
+ """
+ Check the reservation creation with specific reservation lines
+ anc compute checkin checkout
+ ----------------
+ Create reservation with correct reservation lines and check
+ the checkin and checkout fields. Take into account that the
+ checkout of the reservation must be the day after the last night
+ (view checkout assertEqual)
+ """
+ # ARRANGE
+ self.create_common_scenario()
+ customer = self.env.ref("base.res_partner_12")
+ today = fields.date.today()
+ tomorrow = fields.date.today() + datetime.timedelta(days=1)
+ two_days_later = fields.date.today() + datetime.timedelta(days=2)
+
+ # ACT
+ reservation = self.env["pms.reservation"].create(
+ {
+ "room_type_id": self.room_type_double.id,
+ "partner_id": customer.id,
+ "pms_property_id": self.property.id,
+ "reservation_line_ids": [
+ (0, False, {"date": today}),
+ (0, False, {"date": tomorrow}),
+ (0, False, {"date": two_days_later}),
+ ],
+ }
+ )
+
+ # ASSERT
+ self.assertEqual(
+ reservation.checkin,
+ today,
+ "The calculated checkin of the reservation does \
+ not correspond to the first day indicated in the dates",
+ )
+ self.assertEqual(
+ reservation.checkout,
+ two_days_later + datetime.timedelta(days=1),
+ "The calculated checkout of the reservation does \
+ not correspond to the last day indicated in the dates",
+ )
+
@freeze_time("1980-11-01")
def test_create_reservation_start_date(self):
# TEST CASE
diff --git a/pms/tests/test_pms_reservation_prices.py b/pms/tests/test_pms_reservation_prices.py
deleted file mode 100644
index 91907f7d0..000000000
--- a/pms/tests/test_pms_reservation_prices.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from odoo.tests.common import SavepointCase
-
-
-class TestPmsFolioInvoice(SavepointCase):
- def setUp(self):
- super(TestPmsFolioInvoice, self).setUp()
-
- def test_price_reservation(self):
- """Test create a reservation, and check price and discounts"""
-
- def test_general_discount_reservation(self):
- """Test a discount in reservation head, and check lines"""
diff --git a/pms_l10n_es/__manifest__.py b/pms_l10n_es/__manifest__.py
index 978999c71..8ea9b4295 100644
--- a/pms_l10n_es/__manifest__.py
+++ b/pms_l10n_es/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "PMS Spanish Adaptation",
- "version": "14.0.1.0.1",
+ "version": "14.0.1.0.2",
"author": "Commit [Sun], Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": True,
@@ -30,6 +30,8 @@
"data/queue_job_function_data.xml",
"security/ir.model.access.csv",
"views/pms_property_views.xml",
+ "views/res_partner_views.xml",
+ "views/pms_log_institution_traveller_report_views.xml",
"wizards/traveller_report.xml",
],
"installable": True,
diff --git a/pms_l10n_es/data/cron_jobs.xml b/pms_l10n_es/data/cron_jobs.xml
index f99af664a..4aaa1853a 100644
--- a/pms_l10n_es/data/cron_jobs.xml
+++ b/pms_l10n_es/data/cron_jobs.xml
@@ -3,7 +3,7 @@
Automatic Send Traveller Report
-
+
1
days
@@ -13,9 +13,9 @@
- model.send_file_gc_async()
+ model.send_file_institution_async()
diff --git a/pms_l10n_es/data/queue_data.xml b/pms_l10n_es/data/queue_data.xml
index 42bfe7236..44bbeb3a4 100644
--- a/pms_l10n_es/data/queue_data.xml
+++ b/pms_l10n_es/data/queue_data.xml
@@ -1,8 +1,8 @@
-
- gc_file_send
+
+ institution_file_send
diff --git a/pms_l10n_es/data/queue_job_function_data.xml b/pms_l10n_es/data/queue_job_function_data.xml
index c59467665..d3021bda8 100644
--- a/pms_l10n_es/data/queue_job_function_data.xml
+++ b/pms_l10n_es/data/queue_job_function_data.xml
@@ -6,7 +6,7 @@
>
send_file_async
-
+
diff --git a/pms_l10n_es/i18n/es.po b/pms_l10n_es/i18n/es.po
index 642802c5c..698a9c072 100644
--- a/pms_l10n_es/i18n/es.po
+++ b/pms_l10n_es/i18n/es.po
@@ -19,25 +19,117 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.0.1\n"
+#. module: pms_l10n_es
+#: model:ir.actions.server,name:pms_l10n_es.autosend_traveller_report_ir_actions_server
+#: model:ir.cron,cron_name:pms_l10n_es.autosend_traveller_report
+#: model:ir.cron,name:pms_l10n_es.autosend_traveller_report
+msgid "Automatic Send Traveller Report"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__birthdate_date
msgid "Birthdate"
msgstr ""
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/models/pms_property.py:0
+#, python-format
+msgid "Connection Established!"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/models/pms_property.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Connection could not be established"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/models/pms_property.py:0
+#, python-format
+msgid "Connection established succesfully"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model,name:pms_l10n_es.model_res_partner
msgid "Contact"
msgstr "Contacto"
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could last files sent"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get last file sent"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get next file name to send."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get property_info."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get token login."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not upload file."
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__create_uid
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__create_uid
+msgid "Created by"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__create_date
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__create_date
+msgid "Created on"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__document_type__d
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__res_partner__document_type__d
msgid "DNI"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__date
+msgid "Date and time"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__file_incidencies_from_institution
+msgid "Detailed file"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__txt_incidencies_from_institution
+msgid "Detailed message"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__display_name
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__display_name
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__display_name
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner__display_name
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__display_name
msgid "Display Name"
msgstr ""
@@ -90,6 +182,22 @@ msgstr ""
msgid "Driving License"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__error_sending_data
+msgid "Error sending data"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Errors (check the pdf file)."
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__ertxaintxa
+msgid "Ertxaintxa (soon)"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__document_type__x
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__res_partner__document_type__x
@@ -106,6 +214,21 @@ msgstr ""
msgid "Female"
msgstr ""
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "File"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__txt_binary
+msgid "File Download"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__txt_message
+msgid "File Preview"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__firstname
#, fuzzy
@@ -117,21 +240,67 @@ msgstr "Nombre"
msgid "Gender"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__guardia_civil
+msgid "Guardia Civil"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.view_property_form_pms_l10n_es
+msgid "Guest information sending settings"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__id
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__id
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__id
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner__id
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__id
msgid "ID"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,help:pms_l10n_es.field_pms_property__institution_property_id
+msgid "Id provided by institution to send data from property."
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__document_type__i
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__res_partner__document_type__i
msgid "Identification Document"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__institution
+msgid "Institution"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__institution_password
+msgid "Institution password"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__institution_property_id
+msgid "Institution property id"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,help:pms_l10n_es.field_pms_property__institution
+msgid "Institution to send daily guest data."
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__institution_user
+msgid "Institution user"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner____last_update
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report____last_update
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property____last_update
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner____last_update
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard____last_update
msgid "Last Modified on"
msgstr ""
@@ -141,11 +310,48 @@ msgstr ""
msgid "Last Name"
msgstr "Apellido"
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__write_uid
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__write_uid
+msgid "Last Updated by"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__write_date
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__write_date
+msgid "Last Updated on"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.ui.menu,name:pms_l10n_es.menu_open_pms_log_institution_traveller_report_form_tree
+msgid "Log institution traveller report"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_form
+msgid "Log institution traveller report detail"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.actions.act_window,name:pms_l10n_es.open_pms_log_institution_traveller_report_form_tree
+msgid "Log of sending files to institutions"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__gender__male
msgid "Male"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__mossos
+msgid "Mossos_d'esquadra (soon)"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__nationality_id
+msgid "Nationality ID"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__gender__other
msgid "Other"
@@ -162,6 +368,36 @@ msgstr ""
msgid "Passport"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,help:pms_l10n_es.field_pms_property__institution_password
+msgid "Password provided by institution to send the data."
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__policia_nacional
+msgid "Policía Nacional"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.traveller_report_wizard
+msgid "Preview file"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model,name:pms_l10n_es.model_pms_property
+msgid "Property"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "Property Ubications"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model,name:pms_l10n_es.model_pms_log_institution_traveller_report
+msgid "Report of daily sending files of travellers to institutions."
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__lastname2
#, fuzzy
@@ -176,12 +412,71 @@ msgstr "Apellido"
msgid "Select a valid document type"
msgstr ""
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.traveller_report_wizard
+msgid "Send file"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Sent succesfully!"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "Size"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__document_type__n
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__res_partner__document_type__n
msgid "Spanish residence permit"
msgstr ""
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Successful file sending"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.view_property_form_pms_l10n_es
+msgid "Test user/password"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "The guest information sending settings is not complete."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "The guest information sending settings is not property updated."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: model:ir.actions.act_window,name:pms_l10n_es.action_traveller_report
+#: model:ir.model,name:pms_l10n_es.model_traveller_report_wizard
+#: model:ir.ui.menu,name:pms_l10n_es.menu_traveller_report
+#, python-format
+msgid "Traveller Report"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__txt_filename
+#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__txt_filename
+msgid "Txt Filename"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,help:pms_l10n_es.field_pms_property__institution_user
+msgid "User provided by institution to send the data."
+msgstr ""
+
#, fuzzy
#~ msgid "Config Settings"
#~ msgstr "res.config.settings"
diff --git a/pms_l10n_es/i18n/pms_l10n_es.pot b/pms_l10n_es/i18n/pms_l10n_es.pot
index e05310a57..d0f97166f 100644
--- a/pms_l10n_es/i18n/pms_l10n_es.pot
+++ b/pms_l10n_es/i18n/pms_l10n_es.pot
@@ -26,12 +26,7 @@ msgid "Birthdate"
msgstr ""
#. module: pms_l10n_es
-#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
-#, python-format
-msgid "Check the GC configuration to send the guests info"
-msgstr ""
-
-#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/models/pms_property.py:0
#: code:addons/pms_l10n_es/models/pms_property.py:0
#, python-format
msgid "Connection Established!"
@@ -39,6 +34,7 @@ msgstr ""
#. module: pms_l10n_es
#: code:addons/pms_l10n_es/models/pms_property.py:0
+#: code:addons/pms_l10n_es/models/pms_property.py:0
#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
#, python-format
msgid "Connection could not be established"
@@ -46,6 +42,7 @@ msgstr ""
#. module: pms_l10n_es
#: code:addons/pms_l10n_es/models/pms_property.py:0
+#: code:addons/pms_l10n_es/models/pms_property.py:0
#, python-format
msgid "Connection established succesfully"
msgstr ""
@@ -56,11 +53,50 @@ msgid "Contact"
msgstr ""
#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could last files sent"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get last file sent"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get next file name to send."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get property_info."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not get token login."
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Could not upload file."
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__create_uid
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__create_uid
msgid "Created by"
msgstr ""
#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__create_date
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__create_date
msgid "Created on"
msgstr ""
@@ -71,8 +107,24 @@ msgstr ""
msgid "DNI"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__date
+msgid "Date and time"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__file_incidencies_from_institution
+msgid "Detailed file"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__txt_incidencies_from_institution
+msgid "Detailed message"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__display_name
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__display_name
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__display_name
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner__display_name
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__display_name
@@ -128,6 +180,17 @@ msgstr ""
msgid "Driving License"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__error_sending_data
+msgid "Error sending data"
+msgstr ""
+
+#. module: pms_l10n_es
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#, python-format
+msgid "Errors (check the pdf file)."
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__ertxaintxa
msgid "Ertxaintxa (soon)"
@@ -149,6 +212,11 @@ msgstr ""
msgid "Female"
msgstr ""
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "File"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__txt_binary
msgid "File Download"
@@ -181,6 +249,7 @@ msgstr ""
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__id
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__id
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property__id
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner__id
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__id
@@ -225,6 +294,7 @@ msgstr ""
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner____last_update
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report____last_update
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_property____last_update
#: model:ir.model.fields,field_description:pms_l10n_es.field_res_partner____last_update
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard____last_update
@@ -237,15 +307,32 @@ msgid "Last Name"
msgstr ""
#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__write_uid
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__write_uid
msgid "Last Updated by"
msgstr ""
#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__write_date
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__write_date
msgid "Last Updated on"
msgstr ""
+#. module: pms_l10n_es
+#: model:ir.ui.menu,name:pms_l10n_es.menu_open_pms_log_institution_traveller_report_form_tree
+msgid "Log institution traveller report"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_form
+msgid "Log institution traveller report detail"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.actions.act_window,name:pms_l10n_es.open_pms_log_institution_traveller_report_form_tree
+msgid "Log of sending files to institutions"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__gender__male
msgid "Male"
@@ -284,7 +371,7 @@ msgstr ""
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_property__institution__policia_nacional
-msgid "Policía Nacional (soon)"
+msgid "Policía Nacional"
msgstr ""
#. module: pms_l10n_es
@@ -297,6 +384,16 @@ msgstr ""
msgid "Property"
msgstr ""
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "Property Ubications"
+msgstr ""
+
+#. module: pms_l10n_es
+#: model:ir.model,name:pms_l10n_es.model_pms_log_institution_traveller_report
+msgid "Report of daily sending files of travellers to institutions."
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_checkin_partner__lastname2
msgid "Second Last Name"
@@ -317,10 +414,16 @@ msgstr ""
#. module: pms_l10n_es
#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
#, python-format
msgid "Sent succesfully!"
msgstr ""
+#. module: pms_l10n_es
+#: model_terms:ir.ui.view,arch_db:pms_l10n_es.pms_log_institution_traveller_report_view_tree
+msgid "Size"
+msgstr ""
+
#. module: pms_l10n_es
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__pms_checkin_partner__document_type__n
#: model:ir.model.fields.selection,name:pms_l10n_es.selection__res_partner__document_type__n
@@ -329,6 +432,9 @@ msgstr ""
#. module: pms_l10n_es
#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
+#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
#, python-format
msgid "Successful file sending"
msgstr ""
@@ -350,12 +456,6 @@ msgstr ""
msgid "The guest information sending settings is not property updated."
msgstr ""
-#. module: pms_l10n_es
-#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
-#, python-format
-msgid "There is no guest information to send."
-msgstr ""
-
#. module: pms_l10n_es
#: code:addons/pms_l10n_es/wizards/traveller_report.py:0
#: model:ir.actions.act_window,name:pms_l10n_es.action_traveller_report
@@ -366,6 +466,7 @@ msgid "Traveller Report"
msgstr ""
#. module: pms_l10n_es
+#: model:ir.model.fields,field_description:pms_l10n_es.field_pms_log_institution_traveller_report__txt_filename
#: model:ir.model.fields,field_description:pms_l10n_es.field_traveller_report_wizard__txt_filename
msgid "Txt Filename"
msgstr ""
diff --git a/pms_l10n_es/models/__init__.py b/pms_l10n_es/models/__init__.py
index 94a36dd6a..2e5d43f5f 100644
--- a/pms_l10n_es/models/__init__.py
+++ b/pms_l10n_es/models/__init__.py
@@ -1,3 +1,4 @@
# from . import res_partner
# from . import pms_checkin_partner
from . import pms_property
+from . import pms_log_institution_traveller_report
diff --git a/pms_l10n_es/models/pms_log_institution_traveller_report.py b/pms_l10n_es/models/pms_log_institution_traveller_report.py
new file mode 100644
index 000000000..2a3e7d76a
--- /dev/null
+++ b/pms_l10n_es/models/pms_log_institution_traveller_report.py
@@ -0,0 +1,22 @@
+from odoo import fields, models
+
+
+class PmsLogInstitutionTravellerReport(models.Model):
+ _name = "pms.log.institution.traveller.report"
+ _description = "Report of daily sending files of travellers to institutions."
+
+ date = fields.Datetime(
+ string="Date and time",
+ default=fields.Datetime.now,
+ )
+ error_sending_data = fields.Boolean(
+ string="Error sending data",
+ required=True,
+ )
+ txt_incidencies_from_institution = fields.Text(
+ string="Detailed message",
+ )
+ file_incidencies_from_institution = fields.Binary(
+ string="Detailed file",
+ )
+ txt_filename = fields.Text()
diff --git a/pms_l10n_es/models/pms_property.py b/pms_l10n_es/models/pms_property.py
index 9a0fba218..e34f02843 100644
--- a/pms_l10n_es/models/pms_property.py
+++ b/pms_l10n_es/models/pms_property.py
@@ -14,7 +14,7 @@ class PmsProperty(models.Model):
institution = fields.Selection(
[
("guardia_civil", "Guardia Civil"),
- ("policia_nacional", "Policía Nacional (soon)"),
+ ("policia_nacional", "Policía Nacional"),
("ertxaintxa", "Ertxaintxa (soon)"),
("mossos", "Mossos_d'esquadra (soon)"),
],
@@ -24,7 +24,6 @@ class PmsProperty(models.Model):
)
institution_property_id = fields.Char(
string="Institution property id",
- size=10,
help="Id provided by institution to send data from property.",
)
institution_user = fields.Char(
@@ -35,30 +34,27 @@ class PmsProperty(models.Model):
help="Password provided by institution to send the data.",
)
- def test_gc_connection(self):
- for pms_property in self:
+ def test_connection(self):
+ headers = {
+ "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 "
+ "Build/MRA58N) AppleWebKit/537.36 (KHTML, like "
+ "Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36",
+ }
+ for record in self:
if (
- pms_property.institution == "guardia_civil"
- and pms_property.institution_property_id
- and pms_property.institution_user
- and pms_property.institution_password
+ record.institution == "guardia_civil"
+ and record.institution_property_id
+ and record.institution_user
+ and record.institution_password
):
-
url = "https://hospederias.guardiacivil.es/"
login_route = "/hospederias/login.do"
logout_route = "/hospederias/logout.do"
-
- headers = {
- "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 "
- "Build/MRA58N) AppleWebKit/537.36 (KHTML, like "
- "Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36",
- }
session = requests.session()
login_payload = {
- "usuario": pms_property.institution_user,
- "pswd": pms_property.institution_password,
+ "usuario": record.institution_user,
+ "pswd": record.institution_password,
}
-
# login
response_login = session.post(
url + login_route,
@@ -66,7 +62,7 @@ class PmsProperty(models.Model):
data=login_payload,
verify=get_module_resource("pms_l10n_es", "static", "cert.pem"),
)
- time.sleep(1)
+ time.sleep(0.1)
# logout
session.get(
url + logout_route,
@@ -96,3 +92,62 @@ class PmsProperty(models.Model):
return message
else:
raise ValidationError(_("Connection could not be established"))
+ elif (
+ record.institution == "policia_nacional"
+ and record.institution_property_id
+ and record.institution_user
+ and record.institution_password
+ ):
+ url = "https://webpol.policia.es/e-hotel"
+ pre_login_route = "/login"
+ login_route = "/execute_login"
+ home_route = "/inicio"
+ logout_route = "/execute_logout"
+ session = requests.session()
+ response_pre_login = session.post(
+ url + pre_login_route,
+ headers=headers,
+ verify=False,
+ )
+ soup = bs(response_pre_login.text, "html.parser")
+ token = soup.select("input[name='_csrf']")[0]["value"]
+ time.sleep(0.1)
+ login_payload = {
+ "username": record.institution_user,
+ "password": record.institution_password,
+ "_csrf": token,
+ }
+ session.post(
+ url + login_route,
+ headers=headers,
+ data=login_payload,
+ verify=False,
+ )
+ time.sleep(0.1)
+ response_home = session.get(
+ url + home_route,
+ headers=headers,
+ verify=False,
+ )
+ soup = bs(response_home.text, "html.parser")
+ login_correct = soup.select("#datosUsuarioBanner")
+ if login_correct:
+ session.post(
+ url + logout_route,
+ headers=headers,
+ verify=False,
+ data={"_csrf": token},
+ )
+
+ message = {
+ "type": "ir.actions.client",
+ "tag": "display_notification",
+ "params": {
+ "title": _("Connection Established!"),
+ "message": _("Connection established succesfully"),
+ "sticky": False,
+ },
+ }
+ return message
+ else:
+ raise ValidationError(_("Connection could not be established"))
diff --git a/pms_l10n_es/security/ir.model.access.csv b/pms_l10n_es/security/ir.model.access.csv
index d8d1060d6..36ef563cc 100644
--- a/pms_l10n_es/security/ir.model.access.csv
+++ b/pms_l10n_es/security/ir.model.access.csv
@@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
user_access_traveller_report_wizard,user_access_traveller_report_wizard,model_traveller_report_wizard,pms.group_pms_user,1,1,1,1
+user_access_traveller_report_logs,user_access_traveller_report_logs,model_pms_log_institution_traveller_report,pms.group_pms_user,1,1,1,1
diff --git a/pms_l10n_es/views/pms_log_institution_traveller_report_views.xml b/pms_l10n_es/views/pms_log_institution_traveller_report_views.xml
new file mode 100644
index 000000000..362167d3a
--- /dev/null
+++ b/pms_l10n_es/views/pms_log_institution_traveller_report_views.xml
@@ -0,0 +1,61 @@
+
+
+
+ pms.log.institution.traveller.report.form
+ pms.log.institution.traveller.report
+
+
+
+
+
+ pms.log.institution.traveller.report.tree
+ pms.log.institution.traveller.report
+
+
+
+
+
+
+
+
+
+
+
+ Log of sending files to institutions
+ pms.log.institution.traveller.report
+ tree,form
+
+
+
diff --git a/pms_l10n_es/views/pms_property_views.xml b/pms_l10n_es/views/pms_property_views.xml
index 53a3f0e34..117bc16e5 100644
--- a/pms_l10n_es/views/pms_property_views.xml
+++ b/pms_l10n_es/views/pms_property_views.xml
@@ -27,7 +27,7 @@