[FIX] Fix access right issues when using actions

This commit is contained in:
Sébastien Alix
2022-01-29 08:29:11 +01:00
parent 2e54ccb6ff
commit 3cdcdb14bf
6 changed files with 12 additions and 11 deletions

View File

@@ -102,8 +102,8 @@ class MrpPlannedOrder(models.Model):
rec.fixed = not rec.fixed
def action_open_linked_mrp_production(self):
action = self.env.ref("mrp.mrp_production_action")
result = action.read()[0]
xmlid = "mrp.mrp_production_action"
result = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
result["context"] = {}
result["domain"] = "[('id','in',%s)]" % self.mrp_production_ids.ids
return result

View File

@@ -249,7 +249,8 @@ class ProductMRPArea(models.Model):
def action_view_stock_moves(self, domain):
self.ensure_one()
action = self.env.ref("stock.stock_move_action").read()[0]
xmlid = "stock.stock_move_action"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
action["domain"] = domain
action["context"] = {}
return action

View File

@@ -39,8 +39,8 @@ class Product(models.Model):
def action_view_mrp_area_parameters(self):
self.ensure_one()
action = self.env.ref("mrp_multi_level.product_mrp_area_action")
result = action.read()[0]
xmlid = "mrp_multi_level.product_mrp_area_action"
result = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
ctx = ast.literal_eval(result.get("context"))
if not ctx:
ctx = {}

View File

@@ -26,8 +26,8 @@ class ProductTemplate(models.Model):
def action_view_mrp_area_parameters(self):
self.ensure_one()
action = self.env.ref("mrp_multi_level.product_mrp_area_action")
result = action.read()[0]
xmlid = self.env.ref("mrp_multi_level.product_mrp_area_action")
result = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
ctx = ast.literal_eval(result.get("context"))
mrp_areas = self.env["mrp.area"].search([])
if "context" not in result:

View File

@@ -748,6 +748,5 @@ class MultiLevelMrp(models.TransientModel):
self._mrp_final_process(self.mrp_area_ids)
# Open MRP inventory screen to show result if manually run:
# Done as sudo to allow non-admin users to read the action.
action = self.env.ref("mrp_multi_level.mrp_inventory_action")
result = action.sudo().read()[0]
return result
xmlid = "mrp_multi_level.mrp_inventory_action"
return self.env["ir.actions.act_window"]._for_xml_id(xmlid)

View File

@@ -19,7 +19,8 @@ class PurchaseOrder(models.Model):
def action_view_mrp(self):
productions = self.subcontract_production_ids
action = self.env.ref("mrp.mrp_production_action").read()[0]
xmlid = "mrp.mrp_production_action"
action = self.env["ir.actions.act_window"]._for_xml_id(xmlid)
if len(productions) > 1:
action["domain"] = [("id", "in", productions.ids)]
elif len(productions) == 1: