diff --git a/account_statement_cancel_line/__init__.py b/account_statement_cancel_line/__init__.py
index 09b61afc..153ef95a 100644
--- a/account_statement_cancel_line/__init__.py
+++ b/account_statement_cancel_line/__init__.py
@@ -22,3 +22,4 @@
import statement # noqa
import statement_line # noqa
+import wizard # noqa
diff --git a/account_statement_cancel_line/__openerp__.py b/account_statement_cancel_line/__openerp__.py
index 84ed975d..b76cd6fe 100644
--- a/account_statement_cancel_line/__openerp__.py
+++ b/account_statement_cancel_line/__openerp__.py
@@ -43,6 +43,7 @@
'init_xml': [],
'update_xml': [
'statement_view.xml',
+ 'wizard/cancel_line_view.xml',
],
'demo_xml': [],
'test': [
diff --git a/account_statement_cancel_line/statement_line.py b/account_statement_cancel_line/statement_line.py
index 0b4e1f48..ec3de506 100644
--- a/account_statement_cancel_line/statement_line.py
+++ b/account_statement_cancel_line/statement_line.py
@@ -97,6 +97,28 @@ class StatementLine(orm.Model):
return res
+ def button_cancel(self, cr, uid, ids, context=None):
+ """Check if a line is reconciled, and cancel it. Return action."""
+ if context is None:
+ context = {}
+
+ for st_line in self.browse(cr, uid, ids, context=context):
+ for move in st_line.move_ids:
+ for move_line in move.line_id:
+ if move_line.reconcile:
+ # ask confirmation, we have some reconciliation already
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'wizard.cancel.line',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': context,
+ }
+
+ # no reconciliation to worry about: we cancel our lines directly then
+ return self.cancel(cr, uid, ids, context=context)
+
def cancel(self, cr, uid, ids, context=None):
"""Cancel one statement line, return action.
diff --git a/account_statement_cancel_line/statement_view.xml b/account_statement_cancel_line/statement_view.xml
index e82921cf..4d3abb0c 100644
--- a/account_statement_cancel_line/statement_view.xml
+++ b/account_statement_cancel_line/statement_view.xml
@@ -15,7 +15,7 @@
string="Confirm transaction"
icon="gtk-ok"
type="object"/>
-
diff --git a/account_statement_cancel_line/wizard/__init__.py b/account_statement_cancel_line/wizard/__init__.py
new file mode 100644
index 00000000..32945b30
--- /dev/null
+++ b/account_statement_cancel_line/wizard/__init__.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+# #
+# Author: Leonardo Pistone
+# Copyright 2014 Camptocamp SA
+# #
+# 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 . #
+# #
+###############################################################################
+"""Account Statement Cancel Line."""
+
+import cancel_line # noqa
diff --git a/account_statement_cancel_line/wizard/cancel_line.py b/account_statement_cancel_line/wizard/cancel_line.py
new file mode 100644
index 00000000..3ba9bea1
--- /dev/null
+++ b/account_statement_cancel_line/wizard/cancel_line.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+###############################################################################
+# #
+# Author: Leonardo Pistone
+# Copyright 2014 Camptocamp SA
+# #
+# 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 . #
+# #
+###############################################################################
+"""Wizard to Cancel a Statement Line."""
+
+from openerp.osv import orm
+
+
+class wizard_cancel_line(orm.TransientModel):
+
+ """Wizard to Cancel a Statement Line."""
+
+ _name = "wizard.cancel.line"
+ _description = "Cancel Line"
+ _columns = {
+ }
+
+ def unreconcile(self, cr, uid, ids, context=None):
+ """Proceed and cancel the statement line, return Action.
+
+ This will delete the move.line and the reconciliation.
+
+ """
+ return self.pool['account.bank.statement.line'].cancel(
+ cr,
+ uid,
+ context['active_ids'],
+ context=context
+ )
diff --git a/account_statement_cancel_line/wizard/cancel_line_view.xml b/account_statement_cancel_line/wizard/cancel_line_view.xml
new file mode 100644
index 00000000..d450054a
--- /dev/null
+++ b/account_statement_cancel_line/wizard/cancel_line_view.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ view.wizard.cancel.line.form
+ wizard.cancel.line
+
+
+
+
+
+
+