← Back to team overview

openerp-community team mailing list archive

lp:~openerp-community/openobject-addons/fix-1100396-account_budget-date_range into lp:openobject-addons/7.0

 

Niels Huylebroeck has proposed merging lp:~openerp-community/openobject-addons/fix-1100396-account_budget-date_range into lp:openobject-addons/7.0.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #1100396 in OpenERP Addons: "[account_budget] crossovered_budget_report fetches practical amount over wrong period"
  https://bugs.launchpad.net/openobject-addons/+bug/1100396

For more details, see:
https://code.launchpad.net/~openerp-community/openobject-addons/fix-1100396-account_budget-date_range/+merge/144936
-- 
https://code.launchpad.net/~openerp-community/openobject-addons/fix-1100396-account_budget-date_range/+merge/144936
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/fix-1100396-account_budget-date_range.
=== modified file 'account_budget/report/crossovered_budget_report.py'
--- account_budget/report/crossovered_budget_report.py	2012-12-06 15:13:16 +0000
+++ account_budget/report/crossovered_budget_report.py	2013-01-25 13:31:22 +0000
@@ -72,7 +72,6 @@
             self.cr.execute('SELECT DISTINCT(analytic_account_id) FROM crossovered_budget_lines WHERE id = ANY(%s)',(budget_ids,))
             an_ids = self.cr.fetchall()
 
-            context = {'wizard_date_from': d_from, 'wizard_date_to': d_to}
             for i in range(0, len(an_ids)):
                 if not an_ids[i][0]:
                     continue
@@ -97,8 +96,17 @@
                 for line in line_id:
                     if line.id in budget_ids:
                         theo = pract = 0.00
-                        theo = c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id], context)[line.id]
-                        pract = c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id], context)[line.id]
+                        # When fetching theoretical/practical amounts we
+                        # want to use the date as closely related to the
+                        # period defined on the budget line, however
+                        # if the user has entered a date which intersects
+                        # the budget_line dates we take that in preference.
+                        ctx = {
+                            'wizard_date_from': max(line.date_from, d_from),
+                            'wizard_date_to': min(line.date_to, d_to),
+                        }
+                        theo = c_b_lines_obj._theo_amt(self.cr, self.uid, [line.id], ctx)[line.id]
+                        pract = c_b_lines_obj._prac_amt(self.cr, self.uid, [line.id], ctx)[line.id]
                         if line.general_budget_id.id in done_budget:
                             for record in result:
                                 if record['b_id'] == line.general_budget_id.id  and record['a_id'] == line.analytic_account_id.id: