mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[FIX] rma: permissions for general users
- Avoid permission blockings on users who doesn't have RMA permissions. - Add activities view on RMA list. [UPD] Update rma.pot rma 12.0.1.3.1
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -270,7 +270,7 @@
|
||||
<field name="name">RMA</field>
|
||||
<field name="res_model">rma</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form,pivot,calendar</field>
|
||||
<field name="view_mode">tree,form,pivot,calendar,activity</field>
|
||||
<field name="context">{"search_default_user_id": uid}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
|
||||
Reference in New Issue
Block a user