diff --git a/mrp_usability/models/product.py b/mrp_usability/models/product.py index 5073b9b..43bb3a9 100644 --- a/mrp_usability/models/product.py +++ b/mrp_usability/models/product.py @@ -12,16 +12,20 @@ class ProductTemplate(models.Model): only one BoM form or a list of BoMs.""" self.ensure_one() if self.bom_count == 1: - action = self.env.ref("mrp.mrp_bom_form_action").read()[0] + action_xml_id = "mrp.mrp_bom_form_action" + action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id) bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.id)]) - action.update({ - "context": {"default_product_tmpl_id": self.id}, - "views": False, - "view_mode": "form,tree", - "res_id": bom.id, - }) + action.update( + { + "context": {"default_product_tmpl_id": self.id}, + "views": False, + "view_mode": "form,tree", + "res_id": bom.id, + } + ) else: - action = self.env.ref("mrp.template_open_bom").read()[0] + action_xml_id = "mrp.template_open_bom" + action = self.env["ir.actions.actions"]._for_xml_id(action_xml_id) return action @@ -32,9 +36,11 @@ class ProductProduct(models.Model): action = super().action_view_bom() bom_target_ids = self.env["mrp.bom"].search(action["domain"]) if len(bom_target_ids) == 1: - action.update({ - "views": False, - "view_mode": "form,tree", - "res_id": bom_target_ids[0].id, - }) + action.update( + { + "views": False, + "view_mode": "form,tree", + "res_id": bom_target_ids[0].id, + } + ) return action