diff --git a/account_statement_cancel_line/__openerp__.py b/account_statement_cancel_line/__openerp__.py
index e7d53d94..11d1dc8d 100644
--- a/account_statement_cancel_line/__openerp__.py
+++ b/account_statement_cancel_line/__openerp__.py
@@ -43,7 +43,9 @@
When the user confirms or cancels the whole statement, we keep the
previous functionality, and then we change the state in all statement
- lines. We also add a warning if any lines are reconciled.
+ lines. We also add a warning if any lines are reconciled. If no lines
+ are reconciled, we show a generic warning because the operation could
+ take a long time.
When the user confirms or cancels a statement line, we update the state
of the line, and if necessary we update the state of the whole
diff --git a/account_statement_cancel_line/statement.py b/account_statement_cancel_line/statement.py
index ce05adfe..131374cf 100644
--- a/account_statement_cancel_line/statement.py
+++ b/account_statement_cancel_line/statement.py
@@ -49,20 +49,20 @@ class Statement(orm.Model):
"""Check if there is any reconciliation. Return action."""
st_line_obj = self.pool['account.bank.statement.line']
for statement in self.browse(cr, uid, ids, context=context):
- if st_line_obj.has_reconciliation(
- cr,
- uid,
- [line.id for line in statement.line_ids],
- context=context):
- # ask confirmation, we have some reconciliation already
- return {
- 'type': 'ir.actions.act_window',
- 'res_model': 'wizard.cancel.statement',
- 'view_type': 'form',
- 'view_mode': 'form',
- 'target': 'new',
- 'context': context,
- }
+ ctx = context.copy()
+ ctx['default_reconcile_warning'] = st_line_obj.has_reconciliation(
+ cr,
+ uid,
+ [line.id for line in statement.line_ids],
+ context=context)
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'wizard.cancel.statement',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': ctx,
+ }
self.do_cancel(cr, uid, ids, context=context)
diff --git a/account_statement_cancel_line/wizard/cancel_statement.py b/account_statement_cancel_line/wizard/cancel_statement.py
index 2fb8a16a..6454a127 100644
--- a/account_statement_cancel_line/wizard/cancel_statement.py
+++ b/account_statement_cancel_line/wizard/cancel_statement.py
@@ -20,7 +20,7 @@
###############################################################################
"""Wizard to Cancel a Statement."""
-from openerp.osv import orm
+from openerp.osv import orm, fields
class wizard_cancel_statement(orm.TransientModel):
@@ -30,9 +30,14 @@ class wizard_cancel_statement(orm.TransientModel):
_name = "wizard.cancel.statement"
_description = "Cancel Statement"
_columns = {
+ 'reconcile_warning': fields.boolean(
+ 'Show reconcile warning',
+ help='This is a hidden field set with a default in the context '
+ 'to choose between two different warning messages in the view.'
+ ),
}
- def unreconcile(self, cr, uid, ids, context=None):
+ def do_cancel_button(self, cr, uid, ids, context=None):
"""Proceed and cancel the statement, return Action.
This will delete the move.line and the reconciliation.
diff --git a/account_statement_cancel_line/wizard/cancel_statement_view.xml b/account_statement_cancel_line/wizard/cancel_statement_view.xml
index 6dd93862..eb7564c1 100644
--- a/account_statement_cancel_line/wizard/cancel_statement_view.xml
+++ b/account_statement_cancel_line/wizard/cancel_statement_view.xml
@@ -7,10 +7,12 @@
wizard.cancel.statement