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"/> -