mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[14.0][MIG] rma*: ir.actions.act_window has different access
right in v14. Actions that read those records need to use `sudo` to allow non-admin users to be able to use these actions.
This commit is contained in:
@@ -18,6 +18,6 @@ class ResPartner(models.Model):
|
||||
|
||||
def action_open_partner_rma(self):
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
result["context"] = {"search_default_partner_id": self.id}
|
||||
return result
|
||||
|
||||
@@ -185,7 +185,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_in_shipments(self):
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
picking_ids = []
|
||||
for line in self.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
@@ -207,7 +207,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_out_shipments(self):
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
picking_ids = []
|
||||
for line in self.rma_line_ids:
|
||||
for move in line.move_ids:
|
||||
@@ -237,7 +237,7 @@ class RmaOrder(models.Model):
|
||||
else:
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
res = self.env.ref("rma.view_rma_line_supplier_form", False)
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
lines = self._get_valid_lines()
|
||||
# choose the view_mode accordingly
|
||||
if len(lines.ids) != 1:
|
||||
@@ -250,7 +250,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_supplier_lines(self):
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
lines = self.rma_line_ids
|
||||
for line_id in lines:
|
||||
related_lines = [line.id for line in line_id.supplier_rma_line_ids]
|
||||
|
||||
@@ -667,7 +667,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def action_view_in_shipments(self):
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
picking_ids = []
|
||||
for line in self:
|
||||
for move in line.move_ids:
|
||||
@@ -689,7 +689,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def action_view_out_shipments(self):
|
||||
action = self.env.ref("stock.action_picking_tree_all")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
picking_ids = []
|
||||
for line in self:
|
||||
for move in line.move_ids:
|
||||
@@ -717,7 +717,7 @@ class RmaOrderLine(models.Model):
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
rma_lines = self.customer_rma_id.ids
|
||||
res = self.env.ref("rma.view_rma_line_form", False)
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
# choose the view_mode accordingly
|
||||
if rma_lines and len(rma_lines) != 1:
|
||||
result["domain"] = rma_lines.ids
|
||||
|
||||
@@ -160,7 +160,7 @@ class RmaLineMakeSupplierRma(models.TransientModel):
|
||||
rma_line_obj.create(rma_line_data)
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
rma_lines = self.item_ids.mapped("line_id.supplier_rma_line_ids").ids
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
result["domain"] = [("id", "in", rma_lines)]
|
||||
return result
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class AccountMove(models.Model):
|
||||
|
||||
def action_view_rma_supplier(self):
|
||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
rma_ids = self.mapped("line_ids.rma_line_ids").ids
|
||||
if rma_ids:
|
||||
# choose the view_mode accordingly
|
||||
@@ -78,7 +78,7 @@ class AccountMove(models.Model):
|
||||
|
||||
def action_view_rma_customer(self):
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
rma_ids = self.mapped("line_ids.rma_line_ids").ids
|
||||
if rma_ids:
|
||||
# choose the view_mode accordingly
|
||||
|
||||
@@ -98,7 +98,7 @@ class RmaRefund(models.TransientModel):
|
||||
if (new_invoice.move_type in ["out_refund", "out_invoice"])
|
||||
else "action_move_in_refund_type"
|
||||
)
|
||||
result = self.env.ref("account.%s" % action).read()[0]
|
||||
result = self.env.ref("account.%s" % action).sudo().read()[0]
|
||||
form_view = self.env.ref("account.move_supplier_form", False)
|
||||
result["views"] = [(form_view and form_view.id or False, "form")]
|
||||
result["res_id"] = new_invoice.id
|
||||
|
||||
@@ -32,7 +32,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
po_ids = self.env["purchase.order"].search([("origin", "=", self.name)]).ids
|
||||
for line in self.rma_line_ids:
|
||||
po_ids += (
|
||||
@@ -43,7 +43,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_origin_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
po_ids = self.mapped("rma_line_ids.purchase_order_line_id.order_id").ids
|
||||
result["domain"] = [("id", "in", po_ids)]
|
||||
return result
|
||||
|
||||
@@ -213,7 +213,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def action_view_purchase_order(self):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
orders = self.mapped("purchase_order_line_ids.order_id")
|
||||
result["domain"] = [("id", "in", orders.ids)]
|
||||
return result
|
||||
|
||||
@@ -20,7 +20,7 @@ class RmaMakePicking(models.TransientModel):
|
||||
po_list.append(procurement.purchase_id.id)
|
||||
if len(po_list):
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
result["domain"] = [("id", "in", po_list)]
|
||||
return result
|
||||
else:
|
||||
|
||||
@@ -118,7 +118,7 @@ class RmaLineMakePurchaseOrder(models.TransientModel):
|
||||
res.append(purchase.id)
|
||||
|
||||
action = self.env.ref("purchase.purchase_rfq")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
result["domain"] = "[('id','in', [" + ",".join(map(str, res)) + "])]"
|
||||
return result
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_repair_order(self):
|
||||
action = self.env.ref("repair.action_repair_order_tree")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
repair_ids = self.mapped("rma_line_ids.repair_ids").ids
|
||||
result["domain"] = [("id", "in", repair_ids)]
|
||||
return result
|
||||
|
||||
@@ -120,7 +120,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def action_view_repair_order(self):
|
||||
action = self.env.ref("repair.action_repair_order_tree")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
repair_ids = self.repair_ids.ids
|
||||
if len(repair_ids) != 1:
|
||||
result["domain"] = [("id", "in", repair_ids)]
|
||||
|
||||
@@ -32,7 +32,7 @@ class RmaOrder(models.Model):
|
||||
|
||||
def action_view_sale_order(self):
|
||||
action = self.env.ref("sale.action_quotations")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
so_ids = self.mapped("rma_line_ids.sale_line_id.order_id").ids
|
||||
result["domain"] = [("id", "in", so_ids)]
|
||||
return result
|
||||
|
||||
@@ -199,7 +199,7 @@ class RmaOrderLine(models.Model):
|
||||
|
||||
def action_view_sale_order(self):
|
||||
action = self.env.ref("sale.action_quotations")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
order_ids = self.mapped("sale_line_ids.order_id").ids
|
||||
result["domain"] = [("id", "in", order_ids)]
|
||||
return result
|
||||
|
||||
@@ -23,7 +23,7 @@ class SaleOrder(models.Model):
|
||||
|
||||
def action_view_rma(self):
|
||||
action = self.env.ref("rma.action_rma_customer_lines")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
rma_ids = self.mapped("rma_line_ids").ids
|
||||
if rma_ids:
|
||||
# choose the view_mode accordingly
|
||||
|
||||
@@ -119,7 +119,7 @@ class RmaLineMakeSaleOrder(models.TransientModel):
|
||||
res.append(sale.id)
|
||||
|
||||
action = self.env.ref("sale.action_orders")
|
||||
result = action.read()[0]
|
||||
result = action.sudo().read()[0]
|
||||
result["domain"] = "[('id','in', [" + ",".join(map(str, res)) + "])]"
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user