diff --git a/account_cancel_invoice_check_voucher/__init__.py b/account_cancel_invoice_check_voucher/__init__.py
new file mode 100644
index 000000000..765843d26
--- /dev/null
+++ b/account_cancel_invoice_check_voucher/__init__.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Vincent Renaville (Camptocamp)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+import account_invoice
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/account_cancel_invoice_check_voucher/__openerp__.py b/account_cancel_invoice_check_voucher/__openerp__.py
new file mode 100644
index 000000000..d9c4d9615
--- /dev/null
+++ b/account_cancel_invoice_check_voucher/__openerp__.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Vincent Renaville (Camptocamp)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+{
+ "name" : "Cancel invoice, check on bank statement",
+ "version" : "1.0",
+ "depends" : ["base", "account","account_voucher","account_cancel"],
+ "author" : "CamptoCamp",
+ "description": """Contraint to not be able to cancel an invoice already import in bank statement with a voucher
+ """,
+ 'website': 'http://www.camptocamp.com',
+ 'init_xml': [],
+ 'update_xml': [
+ ],
+ 'demo_xml': [],
+ 'installable': True,
+ 'active': False,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/account_cancel_invoice_check_voucher/account_invoice.py b/account_cancel_invoice_check_voucher/account_invoice.py
new file mode 100644
index 000000000..23ba03a2c
--- /dev/null
+++ b/account_cancel_invoice_check_voucher/account_invoice.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2012 Camptocamp (http://www.camptocamp.com)
+# All Right Reserved
+#
+# Author : Vincent Renaville (Camptocamp)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+from tools.translate import _
+from osv import osv
+from openerp.osv.orm import TransientModel
+
+class account_invoice(TransientModel):
+ _inherit = "account.invoice"
+
+ def action_cancel(self, cr, uid, ids, *args):
+ ###
+ invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
+ for i in invoices:
+ if i['move_id']:
+ ## This invoice have a move line, we search move_line converned by this move
+ cr.execute("""select (select name from account_bank_statement where id = statement_id) as statement_name,
+ ((select date from account_bank_statement where id = statement_id)) as statement_date,
+ name from account_bank_statement_line where voucher_id in
+ ( select voucher_id from account_voucher_line where move_line_id in (
+ select id from account_move_line where move_id = %s ))""", (i['move_id'][0],))
+ statement_lines = cr.dictfetchall()
+ if statement_lines:
+ raise osv.except_osv(_('Error !'),
+ _('Invoice already import in bank statment (%s) at %s on line %s'
+ % (statement_lines[0]['statement_name'],
+ statement_lines[0]['statement_date'],
+ statement_lines[0]['name'],)))
+
+
+
+ return super(account_invoice,self).action_cancel(cr, uid, ids, *args)