[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
This commit is contained in:
Nicolas Martinelli
2017-01-30 16:51:29 +01:00
parent 59a700c8e6
commit 3f7c25da24
+3 -3
View File
@@ -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]