changeset 1c1703362a8f in modules/account_budget:6.2
details: 
https://hg.tryton.org/modules/account_budget?cmd=changeset&node=1c1703362a8f
description:
        Use only standard period for budget

        Otherwise when fiscal year is closed, the actual amount is empty 
because it
        will include the closing adjustment period.

        issue11041
        review389401002
        (grafted from 138ad83e05b4927ddb9b1dbbd87a7038e22308f0)
diffstat:

 account.py |  20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diffs (72 lines):

diff -r 37563e3eb883 -r 1c1703362a8f account.py
--- a/account.py        Sat Nov 20 13:42:08 2021 +0100
+++ b/account.py        Tue Dec 21 23:17:02 2021 +0100
@@ -265,6 +265,7 @@
         'account.period', None, None, "Periods",
         domain=[
             ('fiscalyear', '=', Eval('fiscalyear', -1)),
+            ('type', '=', 'standard'),
             ],
         depends=['fiscalyear'])
 
@@ -523,6 +524,7 @@
     def _get_amount_query(cls, records, context):
         pool = Pool()
         Line = pool.get('account.move.line')
+        Period = pool.get('account.period')
 
         table = cls.__table__()
         children = cls.__table__()
@@ -532,7 +534,10 @@
         red_sql = reduce_ids(table.id, [r.id for r in records])
         periods = Transaction().context.get('periods')
         if not periods:
-            periods = None
+            periods = [p.id for p in Period.search([
+                        ('fiscalyear', '=', context.get('fiscalyear')),
+                        ('type', '=', 'standard'),
+                        ])]
         with Transaction().set_context(context, periods=periods):
             query_where, _ = Line.query_get(line)
         return (table
@@ -597,7 +602,10 @@
         'on_change_with_fiscalyear')
     period = fields.Many2One(
         'account.period', "Period", required=True,
-        domain=[('fiscalyear', '=', Eval('fiscalyear', -1))],
+        domain=[
+            ('fiscalyear', '=', Eval('fiscalyear', -1)),
+            ('type', '=', 'standard'),
+            ],
         depends=['fiscalyear'])
     currency = fields.Function(
         fields.Many2One('currency.currency', "Currency"),
@@ -662,6 +670,7 @@
         BudgetLine = pool.get('account.budget.line')
         Move = pool.get('account.move')
         MoveLine = pool.get('account.move.line')
+        Period = pool.get('account.period')
 
         table = cls.__table__()
         budget_line = BudgetLine.__table__()
@@ -673,7 +682,11 @@
         red_sql = reduce_ids(table.id, [r.id for r in records])
         periods = Transaction().context.get('periods')
         if not periods:
-            periods = None
+            periods = [p.id for p in Period.search([
+                        ('fiscalyear', '=', context.get('fiscalyear')),
+                        ('type', '=', 'standard'),
+                        ])]
+
         with Transaction().set_context(context, periods=periods):
             query_where, _ = MoveLine.query_get(line)
         return (table
@@ -809,6 +822,7 @@
         Period = pool.get('account.budget.line.period')
         account_periods = AccountPeriod.search([
                 ('fiscalyear', '=', self.record.budget.fiscalyear.id),
+                ('type', '=', 'standard'),
                 ])
         periods = self.record.create_period(self.start.method, account_periods)
         Period.save(periods)

Reply via email to