[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:
parent
6dd5071952
commit
b1bd0c6cfa
|
@ -12,11 +12,17 @@ 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):
|
||||
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."))
|
||||
|
|
Loading…
Reference in New Issue