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

Module: Sales Invoice Plan

Entity: sale.invoice.plan

Compute Method: _compute_amount

Inputs Method Outputs
for rec in self:
            amount_untaxed = rec.sale_id._origin.amount_untaxed
            if not amount_untaxed:
                continue
            # With invoice already created, no recompute
            if rec.invoiced:
                rec.amount = rec.amount_invoiced
                rec.percent = rec.amount / amount_untaxed * 100
                continue
            # For last line, amount is the left over
            if rec.last:
                installments = rec.sale_id.invoice_plan_ids.filtered(
                    lambda plan: plan.invoice_type == "installment"
                )
                prev_amount = sum((installments - rec).mapped("amount"))
                rec.amount = amount_untaxed - prev_amount
                continue
            rec.amount = rec.percent * amount_untaxed / 100

Back to entity