# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from openerp import models, api, _
from openerp.exceptions import Warning


class BankStatement(models.Model):
    _inherit = 'account.bank.statement'

    @api.multi
    def button_draft(self):
        self.state = 'draft'

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."))
        return super(BankStatementLine, self).cancel()

@@ -318,16 +318,161 @@
 draft'%0A%0A
+    @api.multi%0A    def button_cancel(self):%0A        return super(BankStatement, self.with_context(bank_statement_cancel=True)).button_cancel()%0A%0A%0A
 class Ba
@@ -577,32 +577,98 @@
 f cancel(self):%0A
+        if not self.env.context.get('bank_statement_cancel'):%0A    
         for line
@@ -677,16 +677,20 @@
 n self:%0A
+    
         
@@ -734,16 +734,20 @@
 nfirm':%0A
+    
         

allow cancel of whole bank statement