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

Module: Purchase Invoice Plan

Entity: purchase.invoice.plan

Compute Method: _compute_amount

View 18.0
Inputs Method Outputs
  • purchase_id
  • purchase_id._origin
  • purchase_id._origin.amount_untaxed
  • invoiced
  • amount_invoiced
  • amount
  • last
  • purchase_id.invoice_plan_ids
  • percent
- for rec in self:
-             amount_untaxed = rec.purchase_id._origin.amount_untaxed
-             # 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.purchase_id.invoice_plan_ids.filtered(
-                     lambda pln: pln.invoice_type == "installment"
-                 )
-                 prev_amount = sum((installments - rec).mapped("amount"))
-                 rec.amount = amount_untaxed - prev_amount
-                 continue
-             rec.amount = rec.percent * amount_untaxed / 100
  • amount
  • percent

Back to entity