mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: property dependent check context property_id
This commit is contained in:
@@ -50,7 +50,10 @@ class PmsBoardServiceLine(models.Model):
|
||||
@api.depends_context("allowed_pms_property_ids")
|
||||
def _compute_amount(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
record.amount = self.env["ir.pms.property"].get_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
@@ -61,7 +64,10 @@ class PmsBoardServiceLine(models.Model):
|
||||
|
||||
def _inverse_amount(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
self.env["ir.pms.property"].set_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
|
||||
@@ -58,7 +58,10 @@ class ProductTemplate(models.Model):
|
||||
@api.depends_context("allowed_pms_property_ids")
|
||||
def _compute_daily_limit(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
record.daily_limit = self.env["ir.pms.property"].get_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
@@ -70,7 +73,10 @@ class ProductTemplate(models.Model):
|
||||
@api.depends_context("allowed_pms_property_ids")
|
||||
def _compute_list_price(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
record.list_price = self.env["ir.pms.property"].get_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
@@ -81,7 +87,10 @@ class ProductTemplate(models.Model):
|
||||
|
||||
def _inverse_daily_limit(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
self.env["ir.pms.property"].set_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
@@ -92,7 +101,10 @@ class ProductTemplate(models.Model):
|
||||
|
||||
def _inverse_list_price(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
pms_property_id = (
|
||||
self.env.context.get("property")
|
||||
or self.env.user.get_active_property_ids()[0]
|
||||
)
|
||||
self.env["ir.pms.property"].set_field_value(
|
||||
pms_property_id, self._name, "list_price", record.id, record.list_price
|
||||
)
|
||||
|
||||
@@ -12,12 +12,6 @@ _logger = logging.getLogger(__name__)
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
property_product_pricelist = fields.Many2one(
|
||||
string="Pricelist",
|
||||
comodel_name="product.pricelist",
|
||||
compute="_compute_product_pricelist",
|
||||
inverse="_inverse_product_pricelist",
|
||||
)
|
||||
reservations_count = fields.Integer(
|
||||
string="Number of Reservations",
|
||||
help="Number of reservations of the partner",
|
||||
@@ -812,31 +806,6 @@ class ResPartner(models.Model):
|
||||
action["context"] = context
|
||||
return action
|
||||
|
||||
@api.depends_context("allowed_pms_property_ids")
|
||||
def _compute_product_pricelist(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
record.property_product_pricelist = self.env[
|
||||
"ir.pms.property"
|
||||
].get_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
"property_product_pricelist",
|
||||
record.id,
|
||||
type(record.property_product_pricelist),
|
||||
)
|
||||
|
||||
def _inverse_product_pricelist(self):
|
||||
for record in self:
|
||||
pms_property_id = self.env.user.get_active_property_ids()[0]
|
||||
self.env["ir.pms.property"].set_field_value(
|
||||
pms_property_id,
|
||||
self._name,
|
||||
"property_product_pricelist",
|
||||
record.id,
|
||||
record.property_product_pricelist,
|
||||
)
|
||||
|
||||
@api.constrains("is_agency", "sale_channel_id")
|
||||
def _check_is_agency(self):
|
||||
for record in self:
|
||||
|
||||
Reference in New Issue
Block a user