diff --git a/stock_picking_create_repair/models/account_move.py b/stock_picking_create_repair/models/account_move.py index 2b6d3f13d5..bd1a6b6723 100644 --- a/stock_picking_create_repair/models/account_move.py +++ b/stock_picking_create_repair/models/account_move.py @@ -8,7 +8,10 @@ class AccountMove(models.Model): _inherit = "account.move" - is_repair = fields.Boolean(string="Is repair", compute="_compute_is_repair") + is_repair = fields.Boolean( + string="Is repair", + compute="_compute_is_repair", + ) amount_total_products_rmas = fields.Monetary( string="Amount repair orders", currency_field="currency_id", @@ -21,7 +24,10 @@ class AccountMove(models.Model): copy=False, ) count_repairs = fields.Integer( - string="Num. repairs", compute="_compute_count_repairs", store=True, copy=False + string="Num. repairs", + compute="_compute_count_repairs", + store=True, + copy=False, ) def _compute_is_repair(self): @@ -58,16 +64,16 @@ def unlink(self): def action_repairs_from_sale(self): self.ensure_one() - action = self.env.ref("repair.action_repair_order_tree") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "repair.action_repair_order_tree" + ) + action["domain"] = expression.AND( [ [("id", "in", self.repair_ids.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def get_rma_to_print(self): repairs = "" diff --git a/stock_picking_create_repair/models/sale_order.py b/stock_picking_create_repair/models/sale_order.py index a1ef7edbfc..bc66e559ec 100644 --- a/stock_picking_create_repair/models/sale_order.py +++ b/stock_picking_create_repair/models/sale_order.py @@ -100,57 +100,57 @@ def _compute_count_pending_repairs(self): def action_devolution_picking_repairs_from_sale(self): self.ensure_one() - action = self.env.ref("stock.stock_picking_action_picking_type") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "stock.stock_picking_action_picking_type" + ) + action["domain"] = expression.AND( [ [("id", "in", self.repair_devolution_picking_ids.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def action_in_picking_repairs_from_sale(self): self.ensure_one() pickings = self._search_pickings_repair(self.type_id.picking_type_repair_in_id) - action = self.env.ref("stock.stock_picking_action_picking_type") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "stock.stock_picking_action_picking_type" + ) + action["domain"] = expression.AND( [ [("id", "in", pickings.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def action_out_picking_repairs_from_sale(self): self.ensure_one() pickings = self._search_pickings_repair(self.type_id.picking_type_repair_out_id) - action = self.env.ref("stock.stock_picking_action_picking_type") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "stock.stock_picking_action_picking_type" + ) + action["domain"] = expression.AND( [ [("id", "in", pickings.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def action_repairs_from_sale(self): self.ensure_one() - action = self.env.ref("repair.action_repair_order_tree") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "repair.action_repair_order_tree" + ) + action["domain"] = expression.AND( [ [("id", "in", self.repair_ids.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def _search_pickings_repair(self, picking_type): cond = [ diff --git a/stock_picking_create_repair/models/stock_picking.py b/stock_picking_create_repair/models/stock_picking.py index 647077663d..852435fbb7 100644 --- a/stock_picking_create_repair/models/stock_picking.py +++ b/stock_picking_create_repair/models/stock_picking.py @@ -8,7 +8,11 @@ class StockPicking(models.Model): _inherit = "stock.picking" - is_repair = fields.Boolean(string="It's repair", default=False, copy=True) + is_repair = fields.Boolean( + string="It's repair", + default=False, + copy=True, + ) created_repair_ids = fields.One2many( string="Created repairs", comodel_name="repair.order", @@ -16,14 +20,24 @@ class StockPicking(models.Model): copy=True, ) repairs_count = fields.Integer( - string="# Repairs", compute="_compute_repairs_count", store=True, copy=True + string="# Repairs", + compute="_compute_repairs_count", + store=True, + copy=True, ) sale_order_id = fields.Many2one( - string="Sale order", comodel_name="sale.order", copy=True + string="Sale order", + comodel_name="sale.order", + copy=True, + ) + untreated_origin = fields.Char( + string="Untreated origin", + copy=True, ) - untreated_origin = fields.Char(string="Untreated origin", copy=True) devolution_sale_order_id = fields.Many2one( - string="Sale order", comodel_name="sale.order", copy=True + string="Sale order", + comodel_name="sale.order", + copy=True, ) @api.depends("created_repair_ids") @@ -62,16 +76,16 @@ def create_repairs_from_picking(self): def action_repairs_from_picking(self): self.ensure_one() - action = self.env.ref("repair.action_repair_order_tree") - action_dict = action.read()[0] if action else {} - domain = expression.AND( + action = self.env["ir.actions.actions"]._for_xml_id( + "repair.action_repair_order_tree" + ) + action["domain"] = expression.AND( [ [("id", "in", self.created_repair_ids.ids)], - safe_eval(action.domain or "[]"), + safe_eval(action.get("domain") or "[]"), ] ) - action_dict.update({"domain": domain}) - return action_dict + return action def action_assign(self): for picking in self: