diff --git a/CHANGELOG b/CHANGELOG index 1e476ce73e..7349c1f44f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Ignore balance of non-deferral move * Add a button to manually reapply rule engine Version 5.6.0 - 2020-05-04 diff --git a/line.py b/line.py index b75986e733..5d269642c3 100644 --- a/line.py +++ b/line.py @@ -218,8 +218,14 @@ class MoveLine(ModelSQL, ModelView): @property def must_have_analytic(self): "If the line must have analytic lines set" + pool = Pool() + FiscalYear = pool.get('account.fiscalyear') if self.account.type: - return self.account.type.statement == 'income' + return self.account.type.statement == 'income' and not ( + # ignore balance move of non-deferral account + self.journal.type == 'situation' + and self.period.type == 'adjustment' + and isinstance(self.move.origin, FiscalYear)) @classmethod def apply_rule(cls, lines): diff --git a/tests/scenario_analytic_account.rst b/tests/scenario_analytic_account.rst index a5c79b6f55..2e84dda0a9 100644 --- a/tests/scenario_analytic_account.rst +++ b/tests/scenario_analytic_account.rst @@ -140,3 +140,47 @@ Check analytic lines are created on posting:: Decimal('73') >>> analytic_line.date == analytic_line.move_line.date True + +Prepare to balance non-deferral accounts:: + + >>> Sequence = Model.get('ir.sequence') + >>> Period = Model.get('account.period') + >>> AccountType = Model.get('account.account.type') + >>> Account = Model.get('account.account') + >>> journal_sequence, = Sequence.find([('code', '=', 'account.journal')]) + >>> journal_closing = Journal() + >>> journal_closing.code = 'CLO' + >>> journal_closing.type = 'situation' + >>> journal_closing.name = "Closing" + >>> journal_closing.sequence = journal_sequence + >>> journal_closing.save() + >>> period_closing = Period() + >>> period_closing.name = "Closing" + >>> period_closing.type = 'adjustment' + >>> period_closing.fiscalyear = fiscalyear + >>> period_closing.start_date = fiscalyear.end_date + >>> period_closing.end_date = fiscalyear.end_date + >>> period_closing.save() + >>> equity, = AccountType.find([('name', '=', 'Equity')]) + >>> account_pl = Account() + >>> account_pl.name = 'P&L' + >>> account_pl.type = equity + >>> account_pl.parent = revenue.parent + >>> account_pl.save() + +Balance non-deferral accounts:: + + >>> balance_non_deferral = Wizard('account.fiscalyear.balance_non_deferral') + >>> balance_non_deferral.form.fiscalyear = fiscalyear + >>> balance_non_deferral.form.journal = journal_closing + >>> balance_non_deferral.form.period = period_closing + >>> balance_non_deferral.form.credit_account = account_pl + >>> balance_non_deferral.form.debit_account = account_pl + >>> balance_non_deferral.execute('balance') + >>> move, = Move.find([ + ... ('state', '=', 'draft'), + ... ('journal', '=', journal_closing.id), + ... ]) + >>> move.click('post') + >>> [l for l in move.lines if l.analytic_lines] + []