mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -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):
|
class ProductProduct(models.Model):
|
||||||
@@ -11,6 +12,12 @@ class ProductProduct(models.Model):
|
|||||||
compute="_compute_board_price",
|
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")
|
@api.depends_context("consumption_date")
|
||||||
def _compute_product_price(self):
|
def _compute_product_price(self):
|
||||||
super(ProductProduct, self)._compute_product_price()
|
super(ProductProduct, self)._compute_product_price()
|
||||||
@@ -35,6 +42,20 @@ class ProductProduct(models.Model):
|
|||||||
else:
|
else:
|
||||||
record.board_price = False
|
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):
|
def price_compute(self, price_type, uom=False, currency=False, company=None):
|
||||||
if self._context.get("board_service"):
|
if self._context.get("board_service"):
|
||||||
price_type = "board_price"
|
price_type = "board_price"
|
||||||
|
|||||||
Reference in New Issue
Block a user