[FIX] repair: do not allow to delete invoiced repair
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 <ryv-odoo@users.noreply.github.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user