diff --git a/mrp_bom_location/__manifest__.py b/mrp_bom_location/__manifest__.py index 9674d806f..4c8f7fc8d 100644 --- a/mrp_bom_location/__manifest__.py +++ b/mrp_bom_location/__manifest__.py @@ -11,5 +11,10 @@ "application": False, "depends": ["mrp"], "data": ["views/mrp_view.xml", "views/report_mrpbomstructure.xml"], + "assets": { + "web.assets_backend": [ + "mrp_bom_location/static/src/xml/mrp_bom_overview_location.xml", + ], + }, "installable": True, } diff --git a/mrp_bom_location/report/bom_structure.py b/mrp_bom_location/report/bom_structure.py index 8b944f5d5..fa9dcf778 100644 --- a/mrp_bom_location/report/bom_structure.py +++ b/mrp_bom_location/report/bom_structure.py @@ -8,24 +8,75 @@ class BomStructureReport(models.AbstractModel): _inherit = "report.mrp.report_bom_structure" @api.model - def _get_bom_lines(self, bom, bom_quantity, product, line_id, level): - res = super(BomStructureReport, self)._get_bom_lines( - bom, bom_quantity, product, line_id, level + 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, + ): + res = super(BomStructureReport, self)._get_bom_data( + bom, + warehouse, + product=product, + line_qty=line_qty, + bom_line=bom_line, + level=level, + parent_bom=parent_bom, + index=index, + product_info=product_info, + ignore_stock=ignore_stock, ) line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom.id)]) - for line in res[0]: - line_id = line_ids.filtered( - lambda l: l.location_id and l.id == line["line_id"] + for line in res["components"]: + bom_line = line_ids.filtered( + lambda l: l.location_id and l.product_id == line["product_id"] ) - line["location_id"] = line_id.location_id or "" + line["location_id"] = bom_line.location_id or "" + if parent_bom and parent_bom.location_id.complete_name: + res["location"] = parent_bom.location_id.complete_name + else: + res["location"] = bom.location_id.complete_name or "" + return res + + @api.model + def _get_component_data( + self, + parent_bom, + warehouse, + bom_line, + line_quantity, + level, + index, + product_info, + ignore_stock=False, + ): + res = super(BomStructureReport, self)._get_component_data( + parent_bom, + warehouse, + bom_line, + line_quantity, + level, + index, + product_info, + ignore_stock=ignore_stock, + ) + # line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", parent_bom.id)]) + res["location"] = parent_bom.location_id.complete_name or "" return res @api.model def _get_pdf_line( - self, bom_id, product_id=False, qty=1, child_bom_ids=None, unfolded=False + self, bom_id, product_id=False, qty=1, unfolded_ids=None, unfolded=False ): res = super(BomStructureReport, self)._get_pdf_line( - bom_id, product_id, qty, child_bom_ids, unfolded + bom_id, product_id, qty, unfolded_ids, unfolded ) line_ids = self.env["mrp.bom.line"].search([("bom_id", "=", bom_id)]) for line in res["lines"]: diff --git a/mrp_bom_location/static/src/xml/mrp_bom_overview_location.xml b/mrp_bom_location/static/src/xml/mrp_bom_overview_location.xml new file mode 100644 index 000000000..a1f223801 --- /dev/null +++ b/mrp_bom_location/static/src/xml/mrp_bom_overview_location.xml @@ -0,0 +1,25 @@ + + + + + Location + + + + + + + + + + diff --git a/mrp_bom_location/views/report_mrpbomstructure.xml b/mrp_bom_location/views/report_mrpbomstructure.xml index 1e104a4e0..5612dc0ce 100644 --- a/mrp_bom_location/views/report_mrpbomstructure.xml +++ b/mrp_bom_location/views/report_mrpbomstructure.xml @@ -1,25 +1,25 @@