Merge pull request #275 from Tecnativa/8.0-payment_order-delete_warning

[IMP] account_banking_payment_export: Protect unlink
This commit is contained in:
Holger Brunn
2016-06-20 09:46:45 +02:00
committed by GitHub

View File

@@ -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.