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_delivered_method

View 19.0 View 20.0
Inputs Method Outputs
  • is_expense
  • product_id
  • product_id.type
  • product_id.service_type
  • qty_delivered_method
  • product_id.reinvoice_policy
- """ Sale module compute delivered qty for product [('type', 'in', ['consu']), ('service_type', '=', 'manual')]
-                 - consu + expense_policy : analytic (sum of analytic unit_amount)
-                 - consu + no expense_policy : manual (set manually on SOL)
-                 - service (+ service_type='manual', the only available option) : manual
+ """Compute the method used to compute the quantity delivered for the given lines.

-             This is true when only sale is installed: sale_stock redifine the behavior for 'consu' type,
-             and sale_timesheet implements the behavior of 'service' + service_type=timesheet.
+         Available choices in `sale`:
+ 
+         - analytic (sum of analytic unit_amount)
+         - manual (set manually on SOL)
        """
+ self.qty_delivered_method = "manual"
for line in self:
            if line.is_expense:
-                 line.qty_delivered_method = 'analytic'
-             else:  # service and consu
-                 line.qty_delivered_method = 'manual'
+                 line.qty_delivered_method = "analytic"
+             elif line.product_id.type == "service":
+                 line.qty_delivered_method = line.product_id.service_type
+             elif line.product_id.type == "consu":
+                 line.qty_delivered_method = line._get_consu_qty_delivered_method()
+ 
+             # If product has a reinvoice policy and no specific delivered method, its delivered
+             # quantities should still be computed through analytic lines.
+             # For other delivery methods, they are expected to add their own quantities to the
+             # quantities already provided by the `_prepare_qty_delivered` method, including
+             # analytic lines quantities for reinvoiceable products.
+             if (
+                 line.qty_delivered_method == "manual"
+                 and line.product_id
+                 and line.product_id.reinvoice_policy != "no"
+             ):
+                 line.qty_delivered_method = "analytic"
  • qty_delivered_method

Back to entity