Merge PR #341 into 13.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2023-03-14 11:08:55 +00:00
2 changed files with 13 additions and 1 deletions

View File

@@ -28,7 +28,9 @@ class StockMove(models.Model):
rma_receiver = self.sudo().mapped("rma_receiver_ids")
rma = self.sudo().mapped("rma_id")
res = super().unlink()
rma_receiver.write({"state": "draft"})
rma_receiver.filtered(lambda x: x.state != "cancelled").write(
{"state": "draft"}
)
rma.update_received_state()
rma.update_replaced_state()
return res

View File

@@ -62,3 +62,13 @@ class Rma(models.Model):
"state": "refunded",
}
)
def action_draft(self):
if self.filtered(lambda r: r.state == "cancelled" and r.phantom_bom_product):
raise UserError(
_(
"To avoid kit quantities inconsistencies it is not possible to convert "
"to draft a cancelled RMA. You should do a new one from the sales order."
)
)
return super().action_draft()