From d1395db4d72495cacef0c6c03bd00f7e0100b9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 4 Jan 2021 21:33:28 +0100 Subject: [PATCH] Allow filtering general ledger by journal As general ledger is historically the consolidation of each journal, it may be useful to permit to display the ledger of each journal. issue8757 review335351002 --- CHANGELOG | 2 ++ account.py | 7 +++++++ fiscalyear.py | 2 +- move.py | 3 +++ view/general_ledger_account_context_form.xml | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c945a9b4f1..3f2abdf2af 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Allow filtering general ledger by journal +* Add journal context to Move.query_get * Add reconciliation to general ledger line * Make move's journal read-only once numbered * Add more term units to aged balance diff --git a/account.py b/account.py index f8870d37aa..d1ecdaaedd 100644 --- a/account.py +++ b/account.py @@ -1826,6 +1826,9 @@ class GeneralLedgerAccountContext(ModelView): depends=['from_date']) company = fields.Many2One('company.company', 'Company', required=True) posted = fields.Boolean('Posted Move', help="Only included posted moves.") + journal = fields.Many2One( + 'account.journal', "Journal", + help="Only included moves from the journal.") @classmethod def default_fiscalyear(cls): @@ -1852,6 +1855,10 @@ class GeneralLedgerAccountContext(ModelView): def default_posted(cls): return Transaction().context.get('posted', False) + @classmethod + def default_journal(cls): + return Transaction().context.get('journal') + @classmethod def default_from_date(cls): return Transaction().context.get('from_date') diff --git a/fiscalyear.py b/fiscalyear.py index ca8751b65e..ee117a15a8 100644 --- a/fiscalyear.py +++ b/fiscalyear.py @@ -298,7 +298,7 @@ class FiscalYear(Workflow, ModelSQL, ModelView): Period.close(periods) with Transaction().set_context(fiscalyear=fiscalyear.id, - date=None, cumulate=True): + date=None, cumulate=True, journal=None): accounts = Account.search([ ('company', '=', fiscalyear.company.id), ]) diff --git a/move.py b/move.py index 1483a5b34e..ada3e6e2f3 100644 --- a/move.py +++ b/move.py @@ -986,6 +986,9 @@ class Line(ModelSQL, ModelView): if context.get('posted'): where &= move.state == 'posted' + if context.get('journal'): + where &= move.journal == context['journal'] + date = context.get('date') from_date, to_date = context.get('from_date'), context.get('to_date') fiscalyear_id = context.get('fiscalyear') diff --git a/view/general_ledger_account_context_form.xml b/view/general_ledger_account_context_form.xml index 3146fd7f2c..d4def84455 100644 --- a/view/general_ledger_account_context_form.xml +++ b/view/general_ledger_account_context_form.xml @@ -17,4 +17,6 @@ this repository contains the full copyright notices and license terms. -->