Merge PR #63 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2021-09-22 17:26:29 +00:00

View File

@@ -1,4 +1,5 @@
from odoo import api, fields, models
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ProductProduct(models.Model):
@@ -11,6 +12,12 @@ class ProductProduct(models.Model):
compute="_compute_board_price",
)
room_type_id = fields.Many2one(
string="Room Type",
comodel_name="pms.room.type",
compute="_compute_room_type_id",
)
@api.depends_context("consumption_date")
def _compute_product_price(self):
super(ProductProduct, self)._compute_product_price()
@@ -35,6 +42,20 @@ class ProductProduct(models.Model):
else:
record.board_price = False
def _compute_room_type_id(self):
for rec in self:
room_type = self.env["pms.room.type"].search(
[
("product_id", "=", rec.id),
]
)
if room_type:
if len(room_type) > 1:
raise ValidationError(
_("More than one room found for the same product")
)
rec.room_type_id = room_type
def price_compute(self, price_type, uom=False, currency=False, company=None):
if self._context.get("board_service"):
price_type = "board_price"