diff --git a/rma/__manifest__.py b/rma/__manifest__.py
index c55334f1..04089d2d 100644
--- a/rma/__manifest__.py
+++ b/rma/__manifest__.py
@@ -3,7 +3,7 @@
{
"name": "Return Merchandise Authorization Management",
"summary": "Return Merchandise Authorization (RMA)",
- "version": "12.0.1.3.0",
+ "version": "12.0.1.3.1",
"development_status": "Beta",
"category": "RMA",
"website": "https://github.com/OCA/rma",
diff --git a/rma/i18n/rma.pot b/rma/i18n/rma.pot
index a7f7ba9b..96bc451a 100644
--- a/rma/i18n/rma.pot
+++ b/rma/i18n/rma.pot
@@ -1308,7 +1308,7 @@ msgid "The owner of records created upon receiving emails on this alias. If this
msgstr ""
#. module: rma
-#: code:addons/rma/models/stock_move.py:60
+#: code:addons/rma/models/stock_move.py:64
#, python-format
msgid "The quantity done for the product '%s' must be equal to its initial demand because the stock move is linked to an RMA (%s)."
msgstr ""
diff --git a/rma/models/account_invoice.py b/rma/models/account_invoice.py
index 731891cf..62c3951d 100644
--- a/rma/models/account_invoice.py
+++ b/rma/models/account_invoice.py
@@ -15,14 +15,16 @@ class AccountInvoice(models.Model):
"""
precision = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
- if self.mapped('invoice_line_ids').filtered(
+ if self.sudo().mapped('invoice_line_ids').filtered(
lambda r: (r.rma_id and float_compare(
r.quantity, r.rma_id.product_uom_qty, precision) < 0)):
raise ValidationError(
_("There is at least one invoice lines whose quantity is "
"less than the quantity specified in its linked RMA."))
res = super().action_invoice_open()
- self.mapped('invoice_line_ids.rma_id').write({'state': 'refunded'})
+ self.sudo().mapped('invoice_line_ids.rma_id').write(
+ {'state': 'refunded'}
+ )
return res
diff --git a/rma/models/stock_move.py b/rma/models/stock_move.py
index c20e64c6..29556146 100644
--- a/rma/models/stock_move.py
+++ b/rma/models/stock_move.py
@@ -30,8 +30,10 @@ class StockMove(models.Model):
)
def unlink(self):
- rma_receiver = self.mapped('rma_receiver_ids')
- rma = self.mapped('rma_id')
+ # A stock user could have no RMA permissions, so the ids wouldn't
+ # be accessible due to record rules.
+ rma_receiver = self.sudo().mapped('rma_receiver_ids')
+ rma = self.sudo().mapped('rma_id')
res = super().unlink()
rma_receiver.write({'state': 'draft'})
rma.update_received_state()
@@ -40,7 +42,9 @@ class StockMove(models.Model):
def _action_cancel(self):
res = super()._action_cancel()
- cancelled_moves = self.filtered(lambda r: r.state == 'cancel')
+ # A stock user could have no RMA permissions, so the ids wouldn't
+ # be accessible due to record rules.
+ cancelled_moves = self.filtered(lambda r: r.state == 'cancel').sudo()
cancelled_moves.mapped('rma_receiver_ids').write({'state': 'draft'})
cancelled_moves.mapped('rma_id').update_received_state()
cancelled_moves.mapped('rma_id').update_replaced_state()
@@ -53,7 +57,7 @@ class StockMove(models.Model):
"""
for move in self.filtered(
lambda r: r.state not in ('done', 'cancel')):
- rma_receiver = move.rma_receiver_ids
+ rma_receiver = move.rma_receiver_ids.sudo()
if (rma_receiver
and move.quantity_done != rma_receiver.product_uom_qty):
raise ValidationError(
@@ -63,12 +67,13 @@ class StockMove(models.Model):
% (move.product_id.name, move.rma_receiver_ids.name)
)
res = super()._action_done()
- move_done = self.filtered(lambda r: r.state == 'done')
- # set RMAs as received
- to_be_received = move_done.mapped('rma_receiver_ids').filtered(
+ move_done = self.filtered(lambda r: r.state == 'done').sudo()
+ # Set RMAs as received. We sudo so we can grant the operation even
+ # if the stock user has no RMA permissions.
+ to_be_received = move_done.sudo().mapped('rma_receiver_ids').filtered(
lambda r: r.state == 'confirmed')
to_be_received.write({'state': 'received'})
- # set RMAs as delivered
+ # Set RMAs as delivered
move_done.mapped('rma_id').update_replaced_state()
move_done.mapped('rma_id').update_returned_state()
return res
@@ -85,7 +90,7 @@ class StockMove(models.Model):
RMA link id.
"""
res = super()._prepare_move_split_vals(qty)
- res['rma_id'] = self.rma_id.id
+ res['rma_id'] = self.sudo().rma_id.id
return res
def _prepare_return_rma_vals(self, original_picking):
diff --git a/rma/views/rma_views.xml b/rma/views/rma_views.xml
index 463a29a3..16f646ff 100644
--- a/rma/views/rma_views.xml
+++ b/rma/views/rma_views.xml
@@ -270,7 +270,7 @@
RMA
rma
form
- tree,form,pivot,calendar
+ tree,form,pivot,calendar,activity
{"search_default_user_id": uid}