[FIX] account_cancel: allow cancel of whole bank statement

This revision is related to 6f355623f0.

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
This commit is contained in:
Denis Ledoux 2015-09-23 15:33:55 +02:00
parent 6dd5071952
commit b1bd0c6cfa
1 changed files with 9 additions and 3 deletions

View File

@ -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()