From 80b02ba23fadd9f2606c123072cdef5cf062fd35 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sun, 15 Aug 2021 17:50:54 +0000 Subject: [PATCH] [FIX] repair: do not allow to delete invoiced repair MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, User was allowed to delete repair order which is linked to posted invoice by moving it to Draft. With this commit, user is not allowed to delete repair order linked to a posted Invoice. closes odoo/odoo#75109 Signed-off-by: Rémy Voet --- addons/repair/models/repair.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 62b798c0081..f8c8d98655d 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -204,10 +204,10 @@ class Repair(models.Model): @api.ondelete(at_uninstall=False) def _unlink_except_confirmed(self): for order in self: + if order.invoice_id and order.invoice_id.posted_before: + raise UserError(_('You can not delete a repair order which is linked to an invoice which has been posted once.')) if order.state not in ('draft', 'cancel'): raise UserError(_('You can not delete a repair order once it has been confirmed. You must first cancel it.')) - if order.state == 'cancel' and order.invoice_id and order.invoice_id.posted_before: - raise UserError(_('You can not delete a repair order which is linked to an invoice which has been posted once.')) @api.model def create(self, vals):