diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index 265a76e6b3e..ffc5c0ad0e2 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -60,11 +60,16 @@ class analytic_account_budget_report(report_sxw.rml_parse): 'theo':0.00, 'pln':0.00, 'prac':0.00, - 'perc':0.00 + 'perc':0.00, + 'date_from': budget_name[0].date_from, + 'date_to': budget_name[0].date_to, } result.append(res) - - line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', b_line_ids), ('crossovered_budget_id','=',budget_ids[i][0])]) + domain_lines = [('id', 'in', b_line_ids), + ('crossovered_budget_id', '=', budget_ids[i][0]), + ('date_from', '<=', d_to), + ('date_to', '>=', d_from)] + line_ids = c_b_lines_obj.search(self.cr, self.uid, domain_lines) line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids) tot_theo = tot_pln = tot_prac = tot_perc = 0 diff --git a/addons/account_budget/report/budget_report.py b/addons/account_budget/report/budget_report.py index cc2274c2eea..3ff1f7d0927 100644 --- a/addons/account_budget/report/budget_report.py +++ b/addons/account_budget/report/budget_report.py @@ -66,8 +66,11 @@ class budget_report(report_sxw.rml_parse): 'perc': 0.00 } result.append(res) - - line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids), ('analytic_account_id','=',an_ids[i][0])]) + domain_lines = [('id', 'in', budget_ids), + ('analytic_account_id','=',an_ids[i][0]), + ('date_from', '<=', d_to), + ('date_to', '>=', d_from)] + line_ids = c_b_lines_obj.search(self.cr, self.uid, domain_lines) line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids) tot_theo = tot_pln = tot_prac = tot_perc = 0.00 diff --git a/addons/account_budget/views/report_analyticaccountbudget.xml b/addons/account_budget/views/report_analyticaccountbudget.xml index dab987d6099..9f6e31aa258 100644 --- a/addons/account_budget/views/report_analyticaccountbudget.xml +++ b/addons/account_budget/views/report_analyticaccountbudget.xml @@ -32,6 +32,8 @@ Planned Amt Practical Amt Perc(%) + Start date + End Date @@ -42,6 +44,8 @@ % + + diff --git a/openerp/models.py b/openerp/models.py index 3b7f35ce7f2..f7b68297e6e 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -5787,16 +5787,19 @@ class BaseModel(object): return RecordCache(self) @api.model - def _in_cache_without(self, field): - """ Make sure ``self`` is present in cache (for prefetching), and return - the records of model ``self`` in cache that have no value for ``field`` - (:class:`Field` instance). + def _in_cache_without(self, field, limit=PREFETCH_MAX): + """ Return records to prefetch that have no value in cache for ``field`` + (:class:`Field` instance), including ``self``. + Return at most ``limit`` records. """ env = self.env prefetch_ids = env.prefetch[self._name] prefetch_ids.update(self._ids) ids = filter(None, prefetch_ids - set(env.cache[field])) - return self.browse(ids) + recs = self.browse(ids) + if limit and len(recs) > limit: + recs = self + (recs - self)[:(limit - len(self))] + return recs @api.model def refresh(self):