mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] Fix access right issues when using actions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user