From d5e3b1d04e6e97de3fed8d14b276c7c91bc02f79 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 10 Apr 2019 12:34:47 +0000 Subject: [PATCH] [FIX] sale_mrp, sale_stock: No delivered_qty computed with partial delivery Steps to reproduce the bug: - Create a consumable or storable final product A with invoicing policy in "delivered quantity" - Create two storable products B and C - Create a BOM kit for A with 1 B and 1 C - Create a SO with 5 qty of A and confirm it - Deliver 3 B and 2 C and either on "No backorder" or "With backorder" Bug: The delivered_qty on the SO line is of course not automatically updated (as in this case, a right value is not computable) but the delivered_qty was not updatable manually and then it was possible to invoice the SO. Co-authored-by: nim-odoo DO NOT FORWARD-PORT opw:1966170 closes odoo/odoo#32583 Signed-off-by: Simon Goffin (sig) --- addons/sale_mrp/models/sale_mrp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/sale_mrp/models/sale_mrp.py b/addons/sale_mrp/models/sale_mrp.py index 68600642c9b..267cea6ab89 100644 --- a/addons/sale_mrp/models/sale_mrp.py +++ b/addons/sale_mrp/models/sale_mrp.py @@ -24,6 +24,16 @@ class SaleOrderLine(models.Model): return 0.0 return super(SaleOrderLine, self)._get_delivered_qty() + @api.multi + def _compute_qty_delivered_updateable(self): + lines = self.env['sale.order.line'] + for line in self: + bom = self.env['mrp.bom']._bom_find(product=line.product_id, company_id=line.company_id.id) + if bom and bom.type == 'phantom' and line.order_id.state == 'sale': + line.qty_delivered_updateable = True + lines |= line + super(SaleOrderLine, self - lines)._compute_qty_delivered_updateable() + @api.multi def _get_bom_component_qty(self, bom): bom_quantity = self.product_uom._compute_quantity(1, bom.product_uom_id)