-
product_id
-
product_uom
-
product_id.uom_id
-
product_id.lst_price
|
dp = self.env["decimal.precision"].precision_get("Product Price")
self.semaphore_active = False
for record in self:
if not record.product_id or not record.product_uom:
continue
semaphore_data = record.product_id._get_semaphore_data()
if not semaphore_data:
continue
record.semaphore_active = True
price_reduce = record._get_semaphore_price_reduce()
price_reduce = record.product_uom._compute_price(
price_reduce, record.product_id.uom_id
)
if (
float_compare(
record.product_id.lst_price
* ((100 - semaphore_data["success"]) / 100),
price_reduce,
precision_digits=dp,
)
<= 0
):
record.semaphore = "success"
elif (
float_compare(
record.product_id.lst_price
* ((100 - semaphore_data["warning"]) / 100),
price_reduce,
precision_digits=dp,
)
<= 0
):
record.semaphore = "warning"
else:
record.semaphore = "danger"
|
|