mirror of
https://github.com/OCA/rma.git
synced 2025-02-16 17:11:47 +02:00
[IMP] rma: set rma to received on invoice delete.
Remove 'waiting_refund' rma state. RMAs go from received to refunded. When the linked refund is deleted the rma is set to received.
This commit is contained in:
@@ -21,11 +21,12 @@ class AccountInvoice(models.Model):
|
||||
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.sudo().mapped('invoice_line_ids.rma_id').write(
|
||||
{'state': 'refunded'}
|
||||
)
|
||||
return res
|
||||
return super().action_invoice_open()
|
||||
|
||||
def unlink(self):
|
||||
rma = self.mapped('invoice_line_ids.rma_id')
|
||||
rma.write({'state': 'received'})
|
||||
return super().unlink()
|
||||
|
||||
|
||||
class AccountInvoiceLine(models.Model):
|
||||
|
||||
@@ -164,7 +164,6 @@ class Rma(models.Model):
|
||||
("draft", "Draft"),
|
||||
("confirmed", "Confirmed"),
|
||||
("received", "Received"),
|
||||
("waiting_refund", "Waiting for refund"),
|
||||
("waiting_return", "Waiting for return"),
|
||||
("waiting_replacement", "Waiting for replacement"),
|
||||
("refunded", "Refunded"),
|
||||
@@ -402,7 +401,7 @@ class Rma(models.Model):
|
||||
def _compute_can_be_locked(self):
|
||||
for r in self:
|
||||
r.can_be_locked = (r.remaining_qty_to_done > 0
|
||||
and r.state in ['received', 'waiting_refund',
|
||||
and r.state in ['received',
|
||||
'waiting_return',
|
||||
'waiting_replacement'])
|
||||
|
||||
@@ -590,7 +589,7 @@ class Rma(models.Model):
|
||||
rma.write({
|
||||
'refund_line_id': line.id,
|
||||
'refund_id': refund.id,
|
||||
'state': 'waiting_refund',
|
||||
'state': 'refunded',
|
||||
})
|
||||
refund.message_post_with_view(
|
||||
'mail.message_origin_link',
|
||||
|
||||
Reference in New Issue
Block a user