[REF] pms: rename overnight -> consumption

This commit is contained in:
miguelpadin
2021-06-03 23:38:54 +02:00
parent 93efcab230
commit 0b88a21db0
12 changed files with 106 additions and 105 deletions

View File

@@ -2681,8 +2681,8 @@ msgid "Employee"
msgstr "Empleado/a"
#. module: pms
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_end_overnight
msgid "End Date Overnight"
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_end_consumption
msgid "End Date Consumption"
msgstr "Fin Noche Pernocta"
#. module: pms
@@ -2691,7 +2691,7 @@ msgid "End date for creation of reservations and folios"
msgstr ""
#. module: pms
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_end_overnight
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_end_consumption
msgid "End date to apply daily pricelist items"
msgstr "Fecha límite para aplicar los ítems de la tarifa diaria"
@@ -7370,8 +7370,8 @@ msgid "Stage"
msgstr ""
#. module: pms
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_start_overnight
msgid "Start Date Overnight"
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_start_consumption
msgid "Start Date Consumption"
msgstr "Fecha de Inicio Durante la Noche"
#. module: pms
@@ -7380,7 +7380,7 @@ msgid "Start date for creation of reservations and folios"
msgstr ""
#. module: pms
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_start_overnight
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_start_consumption
msgid "Start date to apply daily pricelist items"
msgstr "Fecha de inicio para aplicar los items de tarifa diarios"

View File

@@ -2532,8 +2532,8 @@ msgid "Employee"
msgstr ""
#. module: pms
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_end_overnight
msgid "End Date Overnight"
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_end_consumption
msgid "End Date Consumption"
msgstr ""
#. module: pms
@@ -2542,7 +2542,7 @@ msgid "End date for creation of reservations and folios"
msgstr ""
#. module: pms
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_end_overnight
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_end_consumption
msgid "End date to apply daily pricelist items"
msgstr ""
@@ -7015,8 +7015,8 @@ msgid "Stage"
msgstr ""
#. module: pms
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_start_overnight
msgid "Start Date Overnight"
#: model:ir.model.fields,field_description:pms.field_product_pricelist_item__date_start_consumption
msgid "Start Date Consumption"
msgstr ""
#. module: pms
@@ -7025,7 +7025,7 @@ msgid "Start date for creation of reservations and folios"
msgstr ""
#. module: pms
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_start_overnight
#: model:ir.model.fields,help:pms.field_product_pricelist_item__date_start_consumption
msgid "Start date to apply daily pricelist items"
msgstr ""

View File

@@ -94,15 +94,15 @@ class ProductPricelist(models.Model):
AND (item.pricelist_id = %s)
AND (item.date_start IS NULL OR item.date_start <=%s)
AND (item.date_end IS NULL OR item.date_end >=%s)
AND (item.date_start_overnight IS NULL
OR item.date_start_overnight <=%s)
AND (item.date_end_overnight IS NULL
OR item.date_end_overnight >=%s)
AND (item.date_start_consumption IS NULL
OR item.date_start_consumption <=%s)
AND (item.date_end_consumption IS NULL
OR item.date_end_consumption >=%s)
GROUP BY item.id
ORDER BY item.applied_on,
/* REVIEW: priotrity date sale / date overnight */
/* REVIEW: priotrity date sale / date consumption */
item.date_end - item.date_start ASC,
item.date_end_overnight - item.date_start_overnight ASC,
item.date_end_consumption - item.date_start_consumption ASC,
NULLIF((SELECT COUNT(1)
FROM product_pricelist_item_pms_property_rel l
WHERE item.id = l.product_pricelist_item_id)
@@ -147,7 +147,7 @@ class ProductPricelist(models.Model):
if record.item_ids:
for item in record.item_ids:
days_diff = (
item.date_end_overnight - item.date_start_overnight
item.date_end_consumption - item.date_start_consumption
).days
if record.pricelist_type == "daily" and (
item.compute_price != "fixed"

View File

@@ -18,12 +18,12 @@ class ProductPricelistItem(models.Model):
ondelete="restrict",
check_pms_properties=True,
)
date_start_overnight = fields.Date(
string="Start Date Overnight",
date_start_consumption = fields.Date(
string="Start Date Consumption",
help="Start date to apply daily pricelist items",
)
date_end_overnight = fields.Date(
string="End Date Overnight",
date_end_consumption = fields.Date(
string="End Date Consumption",
help="End date to apply daily pricelist items",
)
board_service_room_type_id = fields.Many2one(

View File

@@ -335,7 +335,7 @@ class TestPmsPricelist(common.SavepointCase):
" item created previously according to the SALE date.",
)
def test_board_service_pricelist_item_apply_overnight_dates(self):
def test_board_service_pricelist_item_apply_consumption_dates(self):
# TEST CASE
# Pricelist item is created to apply on board services
# at CONSUMPTION date.
@@ -349,8 +349,8 @@ class TestPmsPricelist(common.SavepointCase):
expected_price = 1000.0
vals = {
"pricelist_id": self.pricelist.id,
"date_start_overnight": date_from,
"date_end_overnight": date_to,
"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,
@@ -379,7 +379,7 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
def test_board_service_pricelist_item_not_apply_overnight_dates(self):
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.
@@ -520,7 +520,7 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the SALE date.",
)
def test_room_type_pricelist_item_apply_overnight_dates(self):
def test_room_type_pricelist_item_apply_consumption_dates(self):
# TEST CASE
# Pricelist item is created to apply on room types
# at CONSUMPTION date.
@@ -534,8 +534,8 @@ class TestPmsPricelist(common.SavepointCase):
expected_price = 1000.0
vals = {
"pricelist_id": self.pricelist.id,
"date_start_overnight": date_from,
"date_end_overnight": date_to,
"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,
@@ -562,7 +562,7 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
def test_room_type_pricelist_item_not_apply_overnight_dates(self):
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.
@@ -701,7 +701,7 @@ class TestPmsPricelist(common.SavepointCase):
" item created previously according to the SALE date.",
)
def test_service_pricelist_item_apply_overnight_dates(self):
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
@@ -714,8 +714,8 @@ class TestPmsPricelist(common.SavepointCase):
expected_price = 1000.0
vals = {
"pricelist_id": self.pricelist.id,
"date_start_overnight": date_from,
"date_end_overnight": date_to,
"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,
@@ -743,7 +743,7 @@ class TestPmsPricelist(common.SavepointCase):
" pricelist item created previously according to the CONSUMPTION date.",
)
def test_service_pricelist_item_not_apply_overnight_dates(self):
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
@@ -796,43 +796,43 @@ class TestPmsPricelist(common.SavepointCase):
{
"compute_price": "fixed",
"pms_property_ids": [self.property1.id, self.property2.id],
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
},
{
"compute_price": "fixed",
"pms_property_ids": False,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"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],
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"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],
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
},
{
"compute_price": "percentage",
"pms_property_ids": False,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
},
{
"compute_price": "fixed",
"pms_property_ids": [self.property1.id],
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=3),
},
]
@@ -847,8 +847,8 @@ class TestPmsPricelist(common.SavepointCase):
"compute_price": tc["compute_price"],
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": tc["date_start_overnight"],
"date_end_overnight": tc["date_end_overnight"],
"date_start_consumption": tc["date_start_consumption"],
"date_end_consumption": tc["date_end_consumption"],
}
)
self.pricelist_test = self.env["product.pricelist"].create(
@@ -870,8 +870,8 @@ class TestPmsPricelist(common.SavepointCase):
"compute_price": "fixed",
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.today()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.today()
+ datetime.timedelta(days=1),
}
)

View File

@@ -141,11 +141,11 @@ class TestPmsPricelistRules(common.SavepointCase):
# - test cases to prioritize fields over other fields:
# 1. applied_on
# 2. date
# 3. date overnight
# 3. date consumption
# 4. num. properties
# 5. id
# - tie
# - no [date_start|date_end|date_start_overnight|date_end_overnight]
# - no [date_start|date_end|date_start_consumption|date_end_consumption]
properties = self.room_type.product_id.pms_property_ids.ids
test_cases = [
{
@@ -212,15 +212,15 @@ class TestPmsPricelistRules(common.SavepointCase):
],
},
{
"name": "sorting OVERNIGHT date min range",
"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_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=6),
"fixed_price": 60.0,
"pms_property_ids": properties,
@@ -229,8 +229,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=10),
"fixed_price": 50.0,
"pms_property_ids": properties,
@@ -239,8 +239,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=3),
"fixed_price": 40.0,
"pms_property_ids": properties,
@@ -329,7 +329,7 @@ class TestPmsPricelistRules(common.SavepointCase):
],
},
{
"name": "prioritize SALE date over OVERNIGHT date",
"name": "prioritize SALE date over CONSUMPTION date",
"expected_price": 120.0 * 3,
"items": [
{
@@ -346,8 +346,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=3),
"fixed_price": 50.0,
"pms_property_ids": properties,
@@ -355,15 +355,15 @@ class TestPmsPricelistRules(common.SavepointCase):
],
},
{
"name": "prioritize OVERNIGHT date over min. num. 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_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=3),
"fixed_price": 120.0,
"pms_property_ids": properties,
@@ -372,8 +372,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"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,
@@ -388,8 +388,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now()
+ datetime.timedelta(days=3),
"fixed_price": 120.0,
"pms_property_ids": properties,
@@ -398,8 +398,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"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,
@@ -414,8 +414,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"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()
@@ -427,8 +427,8 @@ class TestPmsPricelistRules(common.SavepointCase):
"pricelist_id": self.pricelist.id,
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now()
"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()
@@ -468,43 +468,43 @@ class TestPmsPricelistRules(common.SavepointCase):
],
},
{
"name": "no overnight DATE START",
"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_overnight": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now(),
"fixed_price": 40.0,
"pms_property_ids": properties,
},
],
},
{
"name": "no overnight DATE END",
"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_overnight": datetime.datetime.now(),
"date_start_consumption": datetime.datetime.now(),
"fixed_price": 40.0,
"pms_property_ids": properties,
},
],
},
{
"name": "only applied overnight in one night",
"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_overnight": datetime.datetime.now(),
"date_end_overnight": datetime.datetime.now(),
"date_start_consumption": datetime.datetime.now(),
"date_end_consumption": datetime.datetime.now(),
"fixed_price": 40.0,
"pms_property_ids": properties,
},

View File

@@ -271,8 +271,8 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
pricelist_item = self.env["product.pricelist.item"].create(
{
"pricelist_id": self.test_pricelist.id,
"date_start_overnight": checkin,
"date_end_overnight": checkin,
"date_start_consumption": checkin,
"date_end_consumption": checkin,
"compute_price": "fixed",
"applied_on": "1_product",
"product_tmpl_id": product_tmpl.id,
@@ -343,8 +343,8 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
# pricelist_item = self.env["product.pricelist.item"].create(
# {
# "pricelist_id": self.test_pricelist.id,
# "date_start_overnight": checkin,
# "date_end_overnight": checkin,
# "date_start_consumption": checkin,
# "date_end_consumption": checkin,
# "compute_price": "fixed",
# "applied_on": "1_product",
# "product_tmpl_id": product_tmpl_id,

View File

@@ -619,8 +619,8 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
"pms_property_ids": [self.test_property.id],
}
).apply_massive_changes()
vals["date_start_overnight"] = date_from
vals["date_end_overnight"] = date_to
vals["date_start_consumption"] = date_from
vals["date_end_consumption"] = date_to
del vals["date_start"]
del vals["date_end"]
@@ -682,12 +682,13 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
# ASSERT
pricelist_items = self.test_pricelist.item_ids.sorted(
key=lambda s: s.date_start_overnight
key=lambda s: s.date_start_consumption
)
# ASSERT
self.assertTrue(
pricelist_items[index].date_start_overnight.timetuple()[6] == index
pricelist_items[index].date_start_consumption.timetuple()[6]
== index
and test_case[index],
"Rule not created on correct day of week",
)

View File

@@ -23,8 +23,8 @@
/>
</xpath>
<xpath expr="//field[@name='date_end']" position="after">
<field name="date_start_overnight" />
<field name="date_end_overnight" />
<field name="date_start_consumption" />
<field name="date_end_consumption" />
</xpath>
<xpath expr="//field[@name='product_id']" position="attributes">
<attribute
@@ -42,8 +42,8 @@
<field name="board_service_room_type_id" />
<field string="Sale Date Start" name="date_start" />
<field string="Sale Date End" name="date_end" />
<field name="date_start_overnight" />
<field name="date_end_overnight" />
<field name="date_start_consumption" />
<field name="date_end_consumption" />
<field name="price" />
<field name="pms_property_ids" widget="many2many_tags" />
</tree>

View File

@@ -19,8 +19,8 @@
expr="//field[@name='item_ids']/tree/field[@name='base']"
position="after"
>
<field name="date_start_overnight" />
<field name="date_end_overnight" />
<field name="date_start_consumption" />
<field name="date_end_consumption" />
<field
name="pms_property_ids"
widget="many2many_tags"

View File

@@ -524,8 +524,8 @@ class AvailabilityWizard(models.TransientModel):
)
)
elif record.date_types == "consumption_dates":
domain.append(("date_start_overnight", ">=", record.start_date))
domain.append(("date_end_overnight", "<=", record.end_date))
domain.append(("date_start_consumption", ">=", record.start_date))
domain.append(("date_end_consumption", "<=", record.end_date))
product_ids = self.generate_product_ids_to_filter(
record.apply_pricelists_on,
@@ -570,9 +570,9 @@ class AvailabilityWizard(models.TransientModel):
items_filtered = False
if record.date_types == "consumption_dates":
items_filtered = items.filtered(
lambda x: x.date_end_overnight
lambda x: x.date_end_consumption
and week_days_to_apply[
x.date_end_overnight.timetuple()[6]
x.date_end_consumption.timetuple()[6]
]
)
elif record.date_types == "sale_dates":
@@ -702,8 +702,8 @@ class AvailabilityWizard(models.TransientModel):
date, datetime.datetime.max.time()
)
else:
vals["date_start_overnight"] = date
vals["date_end_overnight"] = date
vals["date_start_consumption"] = date
vals["date_end_consumption"] = date
return vals
@api.model

View File

@@ -466,8 +466,8 @@
<field name="board_service_room_type_id" />
<field string="Sale Date Start" name="date_start" />
<field string="Sale Date End" name="date_end" />
<field name="date_start_overnight" />
<field name="date_end_overnight" />
<field name="date_start_consumption" />
<field name="date_end_consumption" />
<field name="price" />
<field name="pms_property_ids" widget="many2many_tags" />
</tree>