diff --git a/pms/__manifest__.py b/pms/__manifest__.py
index 5f5e05f6d..965ad2ae1 100644
--- a/pms/__manifest__.py
+++ b/pms/__manifest__.py
@@ -59,6 +59,7 @@
"views/pms_shared_room_views.xml",
"views/res_partner_views.xml",
"views/product_pricelist_views.xml",
+ "views/product_pricelist_item_views.xml",
"views/product_template_views.xml",
"views/webclient_templates.xml",
"views/ir_sequence_views.xml",
diff --git a/pms/models/__init__.py b/pms/models/__init__.py
index 8f3a54565..1547464c0 100644
--- a/pms/models/__init__.py
+++ b/pms/models/__init__.py
@@ -28,6 +28,7 @@ from . import pms_room_type_restriction_item
from . import pms_reservation_line
from . import pms_checkin_partner
from . import product_pricelist
+from . import product_pricelist_item
from . import res_partner
# from . import mail_compose_message
diff --git a/pms/models/pms_reservation_line.py b/pms/models/pms_reservation_line.py
index ed39c49dd..a844d9f25 100644
--- a/pms/models/pms_reservation_line.py
+++ b/pms/models/pms_reservation_line.py
@@ -128,11 +128,16 @@ class PmsReservationLine(models.Model):
"reservation_id.pricelist_id",
"reservation_id.room_type_id",
"reservation_id.reservation_type",
+ "reservation_id.pms_property_id",
)
def _compute_price(self):
for line in self:
reservation = line.reservation_id
- if not reservation.room_type_id or not reservation.pricelist_id:
+ if (
+ not reservation.room_type_id
+ or not reservation.pricelist_id
+ or not reservation.pms_property_id
+ ):
line.price = 0
elif line._recompute_price():
room_type_id = reservation.room_type_id.id
@@ -145,6 +150,7 @@ class PmsReservationLine(models.Model):
date=line.date,
pricelist=reservation.pricelist_id.id,
uom=product.uom_id.id,
+ property=reservation.pms_property_id.id,
)
line.price = self.env["account.tax"]._fix_tax_included_price_company(
line._get_display_price(product),
@@ -174,7 +180,12 @@ class PmsReservationLine(models.Model):
self.ensure_one()
origin = self._origin.reservation_id
new = self.reservation_id
- price_fields = ["pricelist_id", "room_type_id", "reservation_type"]
+ price_fields = [
+ "pricelist_id",
+ "room_type_id",
+ "reservation_type",
+ "pms_property_id",
+ ]
if (
any(origin[field] != new[field] for field in price_fields)
or self._origin.price == 0
@@ -274,7 +285,6 @@ class PmsReservationLine(models.Model):
date=self.date,
uom=product.uom_id.id,
)
-
final_price, rule_id = self.reservation_id.pricelist_id.with_context(
product_context
).get_product_price_rule(product, 1.0, self.reservation_id.partner_id)
diff --git a/pms/models/pms_room.py b/pms/models/pms_room.py
index 461640c84..2dd600708 100644
--- a/pms/models/pms_room.py
+++ b/pms/models/pms_room.py
@@ -32,7 +32,6 @@ class PmsRoom(models.Model):
"pms.property",
store=True,
readonly=True,
- domain="[('id', 'in', room_type_id.pms_property_ids)]",
)
room_type_id = fields.Many2one(
"pms.room.type", "Property Room Type", required=True, ondelete="restrict"
diff --git a/pms/models/product_pricelist.py b/pms/models/product_pricelist.py
index 33c314a60..20c7fe4db 100644
--- a/pms/models/product_pricelist.py
+++ b/pms/models/product_pricelist.py
@@ -51,3 +51,21 @@ class ProductPricelist(models.Model):
# "different property."
# )
# )
+
+ def _compute_price_rule_get_items(
+ self, products_qty_partner, date, uom_id, prod_tmpl_ids, prod_ids, categ_ids
+ ):
+ items = super(ProductPricelist, self)._compute_price_rule_get_items(
+ products_qty_partner, date, uom_id, prod_tmpl_ids, prod_ids, categ_ids
+ )
+ # Discard the rules with defined properties other than the context,
+ # and we reorder the rules to return the most concrete property rule first
+ if "property" in self._context:
+ return items.filtered(
+ lambda i: not i.pms_property_ids
+ or self._context["property"] in i.pms_property_ids.ids
+ ).sorted(
+ key=lambda s: ((not s.pms_property_ids, s), len(s.pms_property_ids))
+ )
+ else:
+ return items
diff --git a/pms/models/product_pricelist_item.py b/pms/models/product_pricelist_item.py
new file mode 100644
index 000000000..0fcb9099c
--- /dev/null
+++ b/pms/models/product_pricelist_item.py
@@ -0,0 +1,11 @@
+# Copyright 2017 Alexandre Díaz, Pablo Quesada, Darío Lodeiros
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from odoo import fields, models
+
+
+class ProductPricelistItem(models.Model):
+ _inherit = "product.pricelist.item"
+
+ pms_property_ids = fields.Many2many(
+ "pms.property", string="Properties", required=False, ondelete="restrict"
+ )
diff --git a/pms/models/product_product.py b/pms/models/product_product.py
new file mode 100644
index 000000000..8f788d13d
--- /dev/null
+++ b/pms/models/product_product.py
@@ -0,0 +1,26 @@
+# Copyright 2017 Alexandre Díaz
+# Copyright 2017 Dario Lodeiros
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from odoo import fields, models
+
+
+class ProductTemplate(models.Model):
+ _inherit = "product.template"
+
+ pms_property_ids = fields.Many2many(
+ "pms.property", string="Properties", required=False, ondelete="restrict"
+ )
+ per_day = fields.Boolean("Unit increment per day")
+ per_person = fields.Boolean("Unit increment per person")
+ consumed_on = fields.Selection(
+ [("before", "Before night"), ("after", "After night")],
+ "Consumed",
+ default="before",
+ )
+ daily_limit = fields.Integer("Daily limit")
+ is_extra_bed = fields.Boolean("Is extra bed", default=False)
+ show_in_calendar = fields.Boolean(
+ "Show in Calendar",
+ default=False,
+ help="Specifies if the product is shown in the calendar information.",
+ )
diff --git a/pms/views/product_pricelist_item_views.xml b/pms/views/product_pricelist_item_views.xml
new file mode 100644
index 000000000..e41566525
--- /dev/null
+++ b/pms/views/product_pricelist_item_views.xml
@@ -0,0 +1,16 @@
+
+
+
+ product.pricelist.item
+
+
+
+
+
+
+
+
diff --git a/pms/views/product_pricelist_views.xml b/pms/views/product_pricelist_views.xml
index c3681e51d..3c548b881 100644
--- a/pms/views/product_pricelist_views.xml
+++ b/pms/views/product_pricelist_views.xml
@@ -13,6 +13,16 @@
+
+
+