diff --git a/account_banking_payment_export/models/account_payment.py b/account_banking_payment_export/models/account_payment.py index 2508b8804..eefebc2ac 100644 --- a/account_banking_payment_export/models/account_payment.py +++ b/account_banking_payment_export/models/account_payment.py @@ -42,6 +42,15 @@ class PaymentOrder(models.Model): for order in self: order.bank_line_count = len(order.bank_line_ids) + @api.multi + def unlink(self): + for order in self: + if order.state not in ('draft', 'cancel'): + raise exceptions.Warning( + _("You cannot remove any order that is not in 'draft' or " + "'cancel' state.")) + return super(PaymentOrder, self).unlink() + @api.multi def launch_wizard(self): """Search for a wizard to launch according to the type.