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

Module: Account Invoice Margin

Entity: account.move.line

Compute Method: _compute_margin

Inputs Method Outputs
for line in self:
            if not line.move_id.is_invoice():
                continue
            if line.move_id and line.move_id.is_purchase_document():
                line.update(
                    {"margin": 0.0, "margin_signed": 0.0, "margin_percent": 0.0}
                )
                continue
            tmp_margin = line.price_subtotal - (line.purchase_price * line.quantity)
            sign = line.move_id.move_type == "out_refund" and -1 or 1
            line.update(
                {
                    "margin": tmp_margin,
                    "margin_signed": tmp_margin * sign,
                    "margin_percent": (
                        tmp_margin / line.price_subtotal * 100.0
                        if line.price_subtotal
                        else 0.0
                    ),
                }
            )

Back to entity