[FIX] mrp: BoM structure report with variants
1. Setup a few variants for a product; 2. Create a BoM for each of the variants with different components/quantities, make sure to specify the product variant field; 3. Go to any of the variants and click Print BoM Structure. Before this commit, it will print the BoM structure for all variants and not only the one selected. Also, it will print in all the variants the same BoM structure. If multiples BoM were selected to print, each variant of the product was printed with each of the BoM structure selected. Now, if you select one BoM, only this is printed. If multiples BoM are printed, each product, and product variant are correctly related to their respective BoM structure. opw-2007939 closes odoo/odoo#34353 Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
@@ -14,8 +14,7 @@ class ReportBomStructure(models.AbstractModel):
|
||||
docs = []
|
||||
for bom_id in docids:
|
||||
bom = self.env['mrp.bom'].browse(bom_id)
|
||||
variant = data and data.get('variant')
|
||||
candidates = variant and self.env['product.product'].browse(variant) or bom.product_tmpl_id.product_variant_ids
|
||||
candidates = bom.product_id or bom.product_tmpl_id.product_variant_ids
|
||||
for product_variant_id in candidates:
|
||||
if data and data.get('childs'):
|
||||
doc = self._get_pdf_line(bom_id, product_id=product_variant_id, qty=float(data.get('quantity')), child_bom_ids=json.loads(data.get('childs')))
|
||||
|
||||
Reference in New Issue
Block a user