From 7997f3b00f503a9b142b0e4df7769f1bd7abc428 Mon Sep 17 00:00:00 2001 From: Haresh Shyara Date: Thu, 16 Aug 2018 12:25:52 +0000 Subject: [PATCH] [IMP] mrp: replace _get_bom_reference by an xpath In the BoM structure and cost report the purpose of _get_bom_reference was to add content with an override in order to display it directly in the column BoM. It could be improved by using the classic display name and add a name to column in order to use an xpath in another module. The function _get_bom and _get_bom_line can also be used in order to introduce extra content directly in the column added with an xpath. Task ID : 1875677 closes odoo/odoo#26493 --- addons/mrp/report/mrp_report_bom_structure.py | 7 ++----- addons/mrp/report/mrp_report_bom_structure.xml | 12 ++++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/addons/mrp/report/mrp_report_bom_structure.py b/addons/mrp/report/mrp_report_bom_structure.py index 3c3a49eb1d2..02379306d06 100644 --- a/addons/mrp/report/mrp_report_bom_structure.py +++ b/addons/mrp/report/mrp_report_bom_structure.py @@ -63,9 +63,6 @@ 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 = {} @@ -116,7 +113,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 '', + 'code': bom and bom.display_name 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, @@ -147,7 +144,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 '', + 'code': line.child_bom_id and line.child_bom_id.display_name or '', 'prod_qty': line_quantity, 'prod_uom': line.product_uom_id.name, 'prod_cost': self.env.user.company_id.currency_id.round(price), diff --git a/addons/mrp/report/mrp_report_bom_structure.xml b/addons/mrp/report/mrp_report_bom_structure.xml index 5cac378d05d..5b9c889a4e4 100644 --- a/addons/mrp/report/mrp_report_bom_structure.xml +++ b/addons/mrp/report/mrp_report_bom_structure.xml @@ -23,7 +23,7 @@ Product - BoM + BoM Quantity Unit of Measure Product Cost @@ -36,7 +36,7 @@ - + @@ -61,7 +61,7 @@ - + Unit Cost @@ -100,7 +100,7 @@ - + @@ -125,7 +125,7 @@ - + Operations @@ -150,7 +150,7 @@ - +