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

Module: Sales

Entity: sale.order.line

Compute Method: _compute_qty_invoiced_posted

View 19.0
Inputs Method Outputs
  • move_id
  • move_id.state
  • move_id.payment_state
  • product_uom_id
  • quantity
  • move_id.direction_sign
+ """
+         This method is almost identical to '_compute_qty_invoiced()'. The only difference lies in the fact that
+         for accounting purposes, we only want the quantities of the posted invoices.
+         We need a dedicated computation because the triggers are different and could lead to incorrect values for
+         'qty_invoiced' when computed together.
+         """
+ for line in self:
+             qty_invoiced_posted = 0.0
+             for invoice_line in line._get_invoice_lines():
+                 if invoice_line.move_id.state == 'posted' or invoice_line.move_id.payment_state == 'invoicing_legacy':
+                     qty_unsigned = invoice_line.product_uom_id._compute_quantity(invoice_line.quantity, line.product_uom_id)
+                     qty_signed = qty_unsigned * -invoice_line.move_id.direction_sign
+                     qty_invoiced_posted += qty_signed
+             line.qty_invoiced_posted = qty_invoiced_posted
  • qty_invoiced_posted

Back to entity