Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Sale Semaphore

Entity: sale.order.line

Compute Method: _compute_semaphore

Inputs Method Outputs
  • 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"

Back to entity