diff --git a/CHANGELOG b/CHANGELOG index f5a3dd98ac..71037d90ed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add button to reconcile statement + Version 4.6.0 - 2017-10-30 * Bug fixes (see mercurial logs for details) * Add generic wizard to import statement from files diff --git a/__init__.py b/__init__.py index b447463d62..dc79e4e15e 100644 --- a/__init__.py +++ b/__init__.py @@ -22,6 +22,7 @@ def register(): Pool.register( PartyReplace, ImportStatement, + ReconcileStatement, module='account_statement', type_='wizard') Pool.register( StatementReport, diff --git a/statement.py b/statement.py index 4da900c1a4..ecf6e123c0 100644 --- a/statement.py +++ b/statement.py @@ -20,7 +20,9 @@ from trytond.modules.company import CompanyReport __all__ = ['Statement', 'Line', 'LineGroup', 'Origin', 'OriginInformation', - 'ImportStatementStart', 'ImportStatement', 'StatementReport'] + 'ImportStatementStart', 'ImportStatement', + 'ReconcileStatement', + 'StatementReport'] _STATES = {'readonly': Eval('state') != 'draft'} _DEPENDS = ['state'] @@ -131,6 +133,8 @@ class Statement(Workflow, ModelSQL, ModelView): state = fields.Selection(STATES, 'State', readonly=True, select=True) validation = fields.Function(fields.Char('Validation'), 'on_change_with_validation') + to_reconcile = fields.Function( + fields.Boolean("To Reconcile"), 'get_to_reconcile') @classmethod def __setup__(cls): @@ -170,6 +174,10 @@ class Statement(Workflow, ModelSQL, ModelView): 'cancel': { 'invisible': ~Eval('state').in_(['draft', 'validated']), }, + 'reconcile': { + 'invisible': Eval('state').in_(['draft', 'cancel']), + 'readonly': ~Eval('to_reconcile'), + }, }) @classmethod @@ -321,6 +329,20 @@ class Statement(Workflow, ModelSQL, ModelView): if self.journal: return self.journal.validation + def get_to_reconcile(self, name=None): + return bool(self.lines_to_reconcile) + + @property + def lines_to_reconcile(self): + lines = [] + for line in self.lines: + if line.move: + for move_line in line.move.lines: + if (move_line.account.reconcile + and not move_line.reconciliation): + lines.append(move_line) + return lines + def _group_key(self, line): key = ( ('number', line.number or Unequal()), @@ -559,6 +581,11 @@ class Statement(Workflow, ModelSQL, ModelView): lines = [l for s in statements for l in s.lines] StatementLine.delete_move(lines) + @classmethod + @ModelView.button_action('account_statement.act_reconcile') + def reconcile(cls, statements): + pass + def origin_mixin(_states, _depends): class Mixin: @@ -1055,5 +1082,21 @@ class ImportStatement(Wizard): return action, data +class ReconcileStatement(Wizard): + "Statement Reconcile" + __name__ = 'account.statement.reconcile' + start = StateAction('account.act_reconcile') + + def do_start(self, action): + pool = Pool() + Statement = pool.get('account.statement') + statements = Statement.browse(Transaction().context['active_ids']) + lines = sum((map(int, s.lines_to_reconcile) for s in statements), []) + return action, { + 'model': 'account.move.line', + 'ids': lines, + } + + class StatementReport(CompanyReport): __name__ = 'account.statement' diff --git a/statement.xml b/statement.xml index 3b4e5025e2..536cb736ae 100644 --- a/statement.xml +++ b/statement.xml @@ -466,6 +466,11 @@ this repository contains the full copyright notices and license terms. --> + + Reconcile Statements + account.statement.reconcile + + Move Lines account.move.line diff --git a/view/statement_form.xml b/view/statement_form.xml index a90db4cadd..599158719e 100644 --- a/view/statement_form.xml +++ b/view/statement_form.xml @@ -32,6 +32,8 @@ this repository contains the full copyright notices and license terms. -->