From 5f77c0154b9b5ed2ddf8b6d495520272324fcfe1 Mon Sep 17 00:00:00 2001 From: mav-adhoc Date: Mon, 4 Aug 2025 17:20:25 +0000 Subject: [PATCH] [FIX]product_currency_mrp: parent_product in get_bom_data X-original-commit: f5c5cc9fea1837804ced5f8cc0c4f8be24ea0366 --- product_currency_mrp/__manifest__.py | 22 +++++++ .../report/mrp_report_bom_structure.py | 62 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/product_currency_mrp/__manifest__.py b/product_currency_mrp/__manifest__.py index 130b2dd6c..c6580fd1f 100644 --- a/product_currency_mrp/__manifest__.py +++ b/product_currency_mrp/__manifest__.py @@ -18,6 +18,7 @@ # ############################################################################## { +<<<<<<< HEAD "name": "Product Currency MRP", "version": "18.0.1.0.0", "category": "Products", @@ -30,6 +31,27 @@ "depends": [ "product_currency", "mrp", +||||||| parent of 2ab32991 (temp) + 'name': 'Product Currency MRP', + 'version': "17.0.1.1.0", + 'category': 'Products', + 'sequence': 14, + 'summary': '', + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'images': [ +======= + 'name': 'Product Currency MRP', + 'version': "17.0.1.2.0", + 'category': 'Products', + 'sequence': 14, + 'summary': '', + 'author': 'ADHOC SA', + 'website': 'www.adhoc.com.ar', + 'license': 'AGPL-3', + 'images': [ +>>>>>>> 2ab32991 (temp) ], "data": [], "demo": [], diff --git a/product_currency_mrp/report/mrp_report_bom_structure.py b/product_currency_mrp/report/mrp_report_bom_structure.py index f0470b1bb..16fc1165b 100644 --- a/product_currency_mrp/report/mrp_report_bom_structure.py +++ b/product_currency_mrp/report/mrp_report_bom_structure.py @@ -5,6 +5,7 @@ class ReportReplenishmentBomStructure(models.AbstractModel): _inherit = "report.mrp.report_bom_structure" @api.model +<<<<<<< HEAD def _get_component_data( self, parent_bom, @@ -21,6 +22,67 @@ def _get_component_data( parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock ) currency = self.env.context.get("force_currency") or self.env.company.currency_id +||||||| parent of 2ab32991 (temp) + def _get_bom_data(self, bom, warehouse, product=False, line_qty=False, bom_line=False, level=0, parent_bom=False, index=0, product_info=False, ignore_stock=False): + """ Here we use the product forced currency uom unit""" + if not self.env.context.get('force_currency'): + self = self.with_context(force_currency=product.currency_id) + res = super(ReportReplenishmentBomStructure, self)._get_bom_data(bom, warehouse, product, line_qty, bom_line, level, parent_bom, index, product_info, ignore_stock) + currency = self.env.context.get('force_currency') or self.env.company.currency_id + res.update({ + 'currency': currency, + 'currency_id': currency.id + }) + is_minimized = self.env.context.get('minimized', False) + current_quantity = line_qty + if bom_line: + current_quantity = bom_line.product_uom_id._compute_quantity(line_qty, bom.product_uom_id) or 0 + if not is_minimized: + if product: + price = product.uom_id._compute_price(product.standard_price, bom.product_uom_id) * current_quantity + res['prod_cost'] = product.currency_id._convert( + price, currency, self.env.company, fields.Date.today(), round=True) + else: + price = bom.product_tmpl_id.uom_id._compute_price(bom.product_tmpl_id.standard_price, bom.product_uom_id) * current_quantity + res['prod_cost'] = bom.product_tmpl_id.currency_id._convert( + price, currency, self.env.company, fields.Date.today(), round=True) + return res + + @api.model + def _get_component_data(self, parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock=False): + res = super()._get_component_data(parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock) + currency = self.env.context.get('force_currency') or self.env.company.currency_id +======= + def _get_bom_data(self, bom, warehouse, product=False, line_qty=False, bom_line=False, level=0, parent_bom=False, parent_product=False, index=0, product_info=False, ignore_stock=False): + """ Here we use the product forced currency uom unit""" + if not self.env.context.get('force_currency'): + self = self.with_context(force_currency=product.currency_id) + res = super(ReportReplenishmentBomStructure, self)._get_bom_data(bom, warehouse, product, line_qty, bom_line, level, parent_bom, parent_product, index, product_info, ignore_stock) + currency = self.env.context.get('force_currency') or self.env.company.currency_id + res.update({ + 'currency': currency, + 'currency_id': currency.id + }) + is_minimized = self.env.context.get('minimized', False) + current_quantity = line_qty + if bom_line: + current_quantity = bom_line.product_uom_id._compute_quantity(line_qty, bom.product_uom_id) or 0 + if not is_minimized: + if product: + price = product.uom_id._compute_price(product.standard_price, bom.product_uom_id) * current_quantity + res['prod_cost'] = product.currency_id._convert( + price, currency, self.env.company, fields.Date.today(), round=True) + else: + price = bom.product_tmpl_id.uom_id._compute_price(bom.product_tmpl_id.standard_price, bom.product_uom_id) * current_quantity + res['prod_cost'] = bom.product_tmpl_id.currency_id._convert( + price, currency, self.env.company, fields.Date.today(), round=True) + return res + + @api.model + def _get_component_data(self, parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock=False): + res = super()._get_component_data(parent_bom, parent_product, warehouse, bom_line, line_quantity, level, index, product_info, ignore_stock) + currency = self.env.context.get('force_currency') or self.env.company.currency_id +>>>>>>> 2ab32991 (temp) company = parent_bom.company_id or self.env.company price = ( bom_line.product_id.uom_id._compute_price(