From 1a446ffbcfdfc60da7544b3750072fe4c4f5c227 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Thu, 9 Dec 2021 13:16:39 +0100 Subject: [PATCH] [FIX] adapt syntax for act_window lookup --- stock_cycle_count/models/stock_cycle_count.py | 15 ++++++++------- stock_cycle_count/models/stock_location.py | 11 ++++++----- stock_move_location/models/stock_picking_type.py | 4 ++-- stock_move_location/wizard/stock_move_location.py | 8 +++++--- .../models/stock_warehouse_orderpoint.py | 11 ++++++----- stock_request/models/stock_picking.py | 5 +++-- stock_request/models/stock_request.py | 5 +++-- stock_request/models/stock_request_order.py | 12 +++++++++--- .../models/vertical_lift_shuttle.py | 2 +- 9 files changed, 43 insertions(+), 30 deletions(-) diff --git a/stock_cycle_count/models/stock_cycle_count.py b/stock_cycle_count/models/stock_cycle_count.py index 53284762f..76ea41f5a 100644 --- a/stock_cycle_count/models/stock_cycle_count.py +++ b/stock_cycle_count/models/stock_cycle_count.py @@ -99,14 +99,15 @@ class StockCycleCount(models.Model): return True def action_view_inventory(self): - action = self.env.ref("stock.action_inventory_form") - result = action.read()[0] - result["context"] = {} + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock.action_inventory_form" + ) + action["context"] = {} adjustment_ids = self.mapped("stock_adjustment_ids").ids if len(adjustment_ids) > 1: - result["domain"] = [("id", "in", adjustment_ids)] + action["domain"] = [("id", "in", adjustment_ids)] elif len(adjustment_ids) == 1: res = self.env.ref("stock.view_inventory_form", False) - result["views"] = [(res and res.id or False, "form")] - result["res_id"] = adjustment_ids and adjustment_ids[0] or False - return result + action["views"] = [(res and res.id or False, "form")] + action["res_id"] = adjustment_ids and adjustment_ids[0] or False + return action diff --git a/stock_cycle_count/models/stock_location.py b/stock_cycle_count/models/stock_location.py index ea315507f..1dd17dafd 100644 --- a/stock_cycle_count/models/stock_location.py +++ b/stock_cycle_count/models/stock_location.py @@ -113,8 +113,9 @@ class StockLocation(models.Model): def action_accuracy_stats(self): self.ensure_one() - action = self.env.ref("stock_cycle_count.act_accuracy_stats") - result = action.read()[0] - new_domain = result["domain"][:-1] + ", ('location_ids', 'in', active_ids)]" - result["domain"] = new_domain - return result + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock_cycle_count.act_accuracy_stats" + ) + new_domain = action["domain"][:-1] + ", ('location_ids', 'in', active_ids)]" + action["domain"] = new_domain + return action diff --git a/stock_move_location/models/stock_picking_type.py b/stock_move_location/models/stock_picking_type.py index 0bb437fd0..d007de0a3 100644 --- a/stock_move_location/models/stock_picking_type.py +++ b/stock_move_location/models/stock_picking_type.py @@ -14,9 +14,9 @@ class StockPickingType(models.Model): ) def action_move_location(self): - action = self.env.ref( + action = self.env["ir.actions.act_window"]._for_xml_id( "stock_move_location.wiz_stock_move_location_action" - ).read()[0] + ) action["context"] = { "default_origin_location_id": self.default_location_src_id.id, "default_destination_location_id": self.default_location_dest_id.id, diff --git a/stock_move_location/wizard/stock_move_location.py b/stock_move_location/wizard/stock_move_location.py index f6461ed59..3c2efc909 100644 --- a/stock_move_location/wizard/stock_move_location.py +++ b/stock_move_location/wizard/stock_move_location.py @@ -221,11 +221,13 @@ class StockMoveLocationWizard(models.TransientModel): self.picking_id = picking return self._get_picking_action(picking.id) - def _get_picking_action(self, pickinig_id): - action = self.env.ref("stock.action_picking_tree_all").read()[0] + def _get_picking_action(self, picking_id): + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock.action_picking_tree_all" + ) form_view = self.env.ref("stock.view_picking_form").id action.update( - {"view_mode": "form", "views": [(form_view, "form")], "res_id": pickinig_id} + {"view_mode": "form", "views": [(form_view, "form")], "res_id": picking_id} ) return action diff --git a/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py b/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py index 3e1b75481..73f8dc455 100644 --- a/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py +++ b/stock_orderpoint_move_link/models/stock_warehouse_orderpoint.py @@ -9,13 +9,14 @@ class StockWarehouseOrderpoint(models.Model): _inherit = "stock.warehouse.orderpoint" def action_view_stock_picking(self): - action = self.env.ref("stock.action_picking_tree_all") - result = action.read()[0] - result["context"] = {} + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock.action_picking_tree_all" + ) + action["context"] = {} picking_ids = ( self.env["stock.move"] .search([("orderpoint_ids", "in", self.id)]) .mapped("picking_id") ) - result["domain"] = "[('id','in',%s)]" % picking_ids.ids - return result + action["domain"] = "[('id','in',%s)]" % picking_ids.ids + return action diff --git a/stock_request/models/stock_picking.py b/stock_request/models/stock_picking.py index cfe03de7c..e4673d68a 100644 --- a/stock_request/models/stock_picking.py +++ b/stock_request/models/stock_picking.py @@ -26,8 +26,9 @@ class StockPicking(models.Model): """ :return dict: dictionary value for created view """ - action = self.env.ref("stock_request.action_stock_request_form").read()[0] - + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock_request.action_stock_request_form" + ) requests = self.mapped("stock_request_ids") if len(requests) > 1: action["domain"] = [("id", "in", requests.ids)] diff --git a/stock_request/models/stock_request.py b/stock_request/models/stock_request.py index 34c1f84d5..f8eea964e 100644 --- a/stock_request/models/stock_request.py +++ b/stock_request/models/stock_request.py @@ -348,8 +348,9 @@ class StockRequest(models.Model): return True def action_view_transfer(self): - action = self.env.ref("stock.action_picking_tree_all").read()[0] - + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock.action_picking_tree_all" + ) pickings = self.mapped("picking_ids") if len(pickings) > 1: action["domain"] = [("id", "in", pickings.ids)] diff --git a/stock_request/models/stock_request_order.py b/stock_request/models/stock_request_order.py index f50e35506..d96add2d5 100644 --- a/stock_request/models/stock_request_order.py +++ b/stock_request/models/stock_request_order.py @@ -248,7 +248,9 @@ class StockRequestOrder(models.Model): return def action_view_transfer(self): - action = self.env.ref("stock.action_picking_tree_all").sudo().read()[0] + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock.action_picking_tree_all" + ) pickings = self.mapped("picking_ids") if len(pickings) > 1: @@ -259,7 +261,9 @@ class StockRequestOrder(models.Model): return action def action_view_stock_requests(self): - action = self.env.ref("stock_request.action_stock_request_form").read()[0] + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock_request.action_stock_request_form" + ) if len(self.stock_request_ids) > 1: action["domain"] = [("order_id", "in", self.ids)] elif self.stock_request_ids: @@ -353,7 +357,9 @@ class StockRequestOrder(models.Model): "administrator." ) ) - action = self.env.ref("stock_request.stock_request_order_action").read()[0] + action = self.env["ir.actions.act_window"]._for_xml_id( + "stock_request.stock_request_order_action" + ) action["views"] = [ (self.env.ref("stock_request.stock_request_order_form").id, "form") ] diff --git a/stock_vertical_lift/models/vertical_lift_shuttle.py b/stock_vertical_lift/models/vertical_lift_shuttle.py index 3ec8c73a5..f7fb3f836 100644 --- a/stock_vertical_lift/models/vertical_lift_shuttle.py +++ b/stock_vertical_lift/models/vertical_lift_shuttle.py @@ -180,7 +180,7 @@ class VerticalLiftShuttle(models.Model): def action_back_to_settings(self): self.release_vertical_lift_tray() action_xmlid = "stock_vertical_lift.vertical_lift_shuttle_action" - action = self.env.ref(action_xmlid).read()[0] + action = self.env["ir.actions.act_window"]._for_xml_id(action_xmlid) action["target"] = "main" return action