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

Compute Method: _compute_margin

Inputs Method Outputs
for order in self:
            sign = -1 if order.is_refund_or_negative() else 1
            if order.is_total_cost_computed:
                order.margin = sum(order.lines.mapped('margin'))
                amount_untaxed = order.currency_id.round(sum(line.price_subtotal for line in order.lines)) * sign
                order.margin_percent = (not float_is_zero(amount_untaxed, precision_rounding=order.currency_id.rounding)
                                        and order.margin / amount_untaxed) \
                                        or 0
            else:
                order.margin = 0
                order.margin_percent = 0

Back to entity