From 3f7c25da245bd6619fe0e4d38ef62f2122f3bae8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 30 Jan 2017 15:20:53 +0100 Subject: [PATCH] [FIX] sale_mrp: find BOM 1. Activate the variant option on sale settings 2. Create a product and set invoicing on delivered qty and make it a stockable product 3. Create 2 attributes, like color red and color blue 4. Odoo creates 2 variants 5. Make a BoM on the product with color red (So on Bom select the product template and the product variant) 6. Set the Bom as "Ship this product as a set of components (kit)" 7. Now create a sale order with sale order line for the product variant BLUE 8. Delivery order is created, deliver the whole delivery order 9. Go back to sale order and see that delivered qty is not updated and thus we can not invoice the lines opw-706423 --- addons/sale_mrp/sale_mrp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale_mrp/sale_mrp.py b/addons/sale_mrp/sale_mrp.py index 4c6a968f514..5e5640f7a5b 100644 --- a/addons/sale_mrp/sale_mrp.py +++ b/addons/sale_mrp/sale_mrp.py @@ -38,9 +38,9 @@ class SaleOrderLine(models.Model): # nothing policy. A product can have several BoMs, we don't know which one was used when the # delivery was created. bom_delivered = {} - for bom in self.product_id.product_tmpl_id.bom_ids: - if bom.type != 'phantom': - continue + bom_id = self.env['mrp.bom']._bom_find(product_id=self.product_id.id, properties=self.property_ids.ids) + bom = self.env['mrp.bom'].browse(bom_id) + if bom and bom.type == 'phantom': bom_delivered[bom.id] = False product_uom_qty_bom = self.env['product.uom']._compute_qty_obj(self.product_uom, self.product_uom_qty, bom.product_uom) bom_exploded = self.env['mrp.bom']._bom_explode(bom, self.product_id, product_uom_qty_bom)[0]