From b1bd0c6cfaa1b8393d592b5e6518bfe7a5cc64be Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 23 Sep 2015 15:33:55 +0200 Subject: [PATCH] [FIX] account_cancel: allow cancel of whole bank statement This revision is related to 6f355623f0632527aae55d02d24a5a06976441c2. The above revision had as goal to not allow the partial cancellation (line per line) of a confirmed bank statement, as it would prevent the ability to reconcile the statement, as reconcilling a confirmed statement it not possible. Nevertheless, cancelling the whole bank statement should be allowed (using the `Cancel Statement` button), as this cancel all lines and re-set the statement in draft. opw-649864 fixes #8568 --- .../account_cancel/models/account_bank_statement.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/account_cancel/models/account_bank_statement.py b/addons/account_cancel/models/account_bank_statement.py index 821014abf37..3e8fb178f2e 100644 --- a/addons/account_cancel/models/account_bank_statement.py +++ b/addons/account_cancel/models/account_bank_statement.py @@ -12,12 +12,18 @@ class BankStatement(models.Model): def button_draft(self): self.state = 'draft' + @api.multi + def button_cancel(self): + return super(BankStatement, self.with_context(bank_statement_cancel=True)).button_cancel() + + class BankStatementLine(models.Model): _inherit = 'account.bank.statement.line' @api.multi def cancel(self): - for line in self: - if line.statement_id.state == 'confirm': - raise Warning(_("Please set the bank statement to New before canceling.")) + if not self.env.context.get('bank_statement_cancel'): + for line in self: + if line.statement_id.state == 'confirm': + raise Warning(_("Please set the bank statement to New before canceling.")) return super(BankStatementLine, self).cancel()