From bb05e833f92645f9ff3f21885f263511954d64a4 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Wed, 8 Aug 2018 17:41:44 +0200 Subject: [PATCH] [IMP] mrp: Show the bom reference on BoM report. Each line that contains a manufacturable product displays its BoM (clickable with an html report). _get_bom_reference function is used in order to add information about BoM in report (e.g plm module add its version). Task id: 1857701 --- addons/mrp/report/mrp_report_bom_structure.py | 6 ++++++ addons/mrp/report/mrp_report_bom_structure.xml | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/addons/mrp/report/mrp_report_bom_structure.py b/addons/mrp/report/mrp_report_bom_structure.py index b66805f8eef..42e18fd5073 100644 --- a/addons/mrp/report/mrp_report_bom_structure.py +++ b/addons/mrp/report/mrp_report_bom_structure.py @@ -54,6 +54,9 @@ class ReportBomStructure(models.AbstractModel): } return self.env.ref('mrp.report_mrp_operation_line').render({'data': values}) + def _get_bom_reference(self, bom): + return bom.display_name + @api.model def _get_report_data(self, bom_id, searchQty=0, searchVariant=False): lines = {} @@ -98,6 +101,7 @@ class ReportBomStructure(models.AbstractModel): 'bom_prod_name': product.display_name, 'currency': self.env.user.company_id.currency_id, 'product': product, + 'code': bom and self._get_bom_reference(bom) or '', 'price': product.uom_id._compute_price(product.standard_price, bom.product_uom_id) * bom_quantity, 'total': sum([op['total'] for op in operations]), 'level': level or 0, @@ -128,6 +132,7 @@ class ReportBomStructure(models.AbstractModel): components.append({ 'prod_id': line.product_id.id, 'prod_name': line.product_id.display_name, + 'code': line.child_bom_id and self._get_bom_reference(line.child_bom_id) or '', 'prod_qty': line_quantity, 'prod_uom': line.product_uom_id.name, 'prod_cost': price, @@ -192,6 +197,7 @@ class ReportBomStructure(models.AbstractModel): 'prod_cost': bom_line['prod_cost'], 'bom_cost': bom_line['total'], 'level': bom_line['level'], + 'code': bom_line['code'] }) if bom_line['child_bom'] and (unfolded or bom_line['child_bom'] in child_bom_ids): line = self.env['mrp.bom.line'].browse(bom_line['line_id']) diff --git a/addons/mrp/report/mrp_report_bom_structure.xml b/addons/mrp/report/mrp_report_bom_structure.xml index b607c146f22..2fd59fce748 100644 --- a/addons/mrp/report/mrp_report_bom_structure.xml +++ b/addons/mrp/report/mrp_report_bom_structure.xml @@ -24,6 +24,7 @@ Product + BoM Quantity Unit of Measure Product Cost @@ -36,6 +37,9 @@ + + + @@ -57,6 +61,7 @@ + Unit Cost @@ -96,6 +101,11 @@ + + + + + @@ -121,6 +131,7 @@ Operations + @@ -144,6 +155,7 @@ + @@ -173,6 +185,9 @@ + + +