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

Module: Point of Sale

Entity: pos.order.line

Compute Method: _compute_margin

View 19.0 View 20.0
Inputs Method Outputs
  • order_id
  • order_id.is_refund
  • product_id
  • product_id.type
  • price_subtotal
  • total_cost
  • currency_id
  • currency_id.rounding
  • margin
for line in self:
-             sign = -1 if line.order_id.is_refund else 1
+             sign = -1 if line.order_id.is_refund_or_negative() else 1
            if line.product_id.type == 'combo':
                line.margin = 0
                line.margin_percent = 0
            else:
                line.margin = (line.price_subtotal * sign) - line.total_cost
-                 line.margin_percent = not float_is_zero(line.price_subtotal, precision_rounding=line.currency_id.rounding) \
-                                         and line.margin / (line.price_subtotal * sign) \
+                 line.margin_percent = (not float_is_zero(line.price_subtotal, precision_rounding=line.currency_id.rounding)
+                                         and line.margin / (line.price_subtotal * sign)) \
                                        or 0
  • margin
  • margin_percent

Back to entity