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

Module: Purchase

Entity: purchase.order.line

Compute Method: _compute_qty_invoiced

View 17.0 View 20.0
Inputs Method Outputs
  • move_id
  • move_id.state
  • move_id.payment_state
  • move_id.move_type
  • product_uom_id
  • quantity
  • product_uom
  • order_id
  • order_id.state
  • product_id
  • product_id.purchase_method
  • product_qty
  • qty_invoiced
  • qty_received
+ invoiced_quantities = self._prepare_qty_invoiced()
for line in self:
-             # compute qty_invoiced
-             qty = 0.0
-             for inv_line in line._get_invoice_lines():
-                 if inv_line.move_id.state not in ['cancel'] or inv_line.move_id.payment_state == 'invoicing_legacy':
-                     if inv_line.move_id.move_type == 'in_invoice':
-                         qty += inv_line.product_uom_id._compute_quantity(inv_line.quantity, line.product_uom)
-                     elif inv_line.move_id.move_type == 'in_refund':
-                         qty -= inv_line.product_uom_id._compute_quantity(inv_line.quantity, line.product_uom)
-             line.qty_invoiced = qty
+             line.qty_invoiced = invoiced_quantities[line]

            # compute qty_to_invoice
-             if line.order_id.state in ['purchase', 'done']:
+             if line.order_id.state == 'purchase':
                if line.product_id.purchase_method == 'purchase':
                    line.qty_to_invoice = line.product_qty - line.qty_invoiced
                else:
                    line.qty_to_invoice = line.qty_received - line.qty_invoiced
            else:
                line.qty_to_invoice = 0
  • qty_invoiced
  • qty_to_invoice

Back to entity