changeset 9dc78c189562 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=9dc78c189562
description:
        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
diffstat:

 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 deletions(-)

diffs (68 lines):

diff -r f9f10965c137 -r 9dc78c189562 CHANGELOG
--- a/CHANGELOG Mon Jan 04 21:29:23 2021 +0100
+++ b/CHANGELOG Mon Jan 04 21:33:28 2021 +0100
@@ -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 -r f9f10965c137 -r 9dc78c189562 account.py
--- a/account.py        Mon Jan 04 21:29:23 2021 +0100
+++ b/account.py        Mon Jan 04 21:33:28 2021 +0100
@@ -1826,6 +1826,9 @@
         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):
@@ -1853,6 +1856,10 @@
         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 -r f9f10965c137 -r 9dc78c189562 fiscalyear.py
--- a/fiscalyear.py     Mon Jan 04 21:29:23 2021 +0100
+++ b/fiscalyear.py     Mon Jan 04 21:33:28 2021 +0100
@@ -298,7 +298,7 @@
             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 -r f9f10965c137 -r 9dc78c189562 move.py
--- a/move.py   Mon Jan 04 21:29:23 2021 +0100
+++ b/move.py   Mon Jan 04 21:33:28 2021 +0100
@@ -986,6 +986,9 @@
         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 -r f9f10965c137 -r 9dc78c189562 
view/general_ledger_account_context_form.xml
--- a/view/general_ledger_account_context_form.xml      Mon Jan 04 21:29:23 
2021 +0100
+++ b/view/general_ledger_account_context_form.xml      Mon Jan 04 21:33:28 
2021 +0100
@@ -17,4 +17,6 @@
     <field name="from_date"/>
     <label name="to_date"/>
     <field name="to_date"/>
+    <label name="journal"/>
+    <field name="journal" widget="selection"/>
 </form>

Reply via email to