From 8efeb4c6fca0131570ed17c02dd822e44f7ade38 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 11 Aug 2017 16:02:27 +0200 Subject: [PATCH 1/3] [FIX] prefetch issues on computed fields (#18799) When deciding to prefetch records (getting records from the cache with no value for the field being fetched), if the field was computed `determine_value` would just get all records, not limited by the normal prefetch limit; for large recordsets this would generate gigantic prefetch lists for records we may not need at all. Fix by applying the `PREFETCH_MAX` limit to records from the cache as is done in `_prefetch_field`. --- openerp/models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openerp/models.py b/openerp/models.py index a9babb84126..4dd70e738d6 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -3206,9 +3206,6 @@ class BaseModel(object): # fetch the records of this model without field_name in their cache records = self._in_cache_without(field) - if len(records) > PREFETCH_MAX: - records = records[:PREFETCH_MAX] | self - # determine which fields can be prefetched if not self.env.in_draft and \ self._context.get('prefetch_fields', True) and \ @@ -5675,16 +5672,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): From eaa95bd0a6139389826416306ba3d7154e88bbce Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 14 Aug 2017 09:53:05 +0200 Subject: [PATCH 2/3] [FIX] tx: don't translate test modules Not published on Transifex --- .tx/config | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.tx/config b/.tx/config index 0e87ee9aafd..00dff4bfaa5 100644 --- a/.tx/config +++ b/.tx/config @@ -1121,13 +1121,3 @@ source_lang = en file_filter = addons/website_twitter/i18n/.po source_file = addons/website_twitter/i18n/website_twitter.pot source_lang = en - -[odoo-8.web_tests] -file_filter = addons/web_tests/i18n/.po -source_file = addons/web_tests/i18n/web_tests.pot -source_lang = en - -[odoo-8.web_tests_demo] -file_filter = addons/web_tests_demo/i18n/.po -source_file = addons/web_tests_demo/i18n/web_tests_demo.pot -source_lang = en From ff30928786961efef66706729286e7f48c754bbd Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 8 Aug 2017 16:08:10 +0200 Subject: [PATCH 3/3] [FIX] account_budget: clearer analytic budget report Before this commit there were two issues: - The date "from and to" set in the wizard weren't working, as in not used at all - The lines in the report did not have a date range, making the understanding of the report difficult after this commit, only the budget lines which dates overlap at least one day of the report's dates will be selected. Also, the first line of the report, containing the budget name also contains the dates on which it applies OPW 743441 Closes #18737 --- .../report/analytic_account_budget_report.py | 11 ++++++++--- addons/account_budget/report/budget_report.py | 7 +++++-- .../views/report_analyticaccountbudget.xml | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/account_budget/report/analytic_account_budget_report.py b/addons/account_budget/report/analytic_account_budget_report.py index 4e3feaf06b7..8bd15aeacba 100644 --- a/addons/account_budget/report/analytic_account_budget_report.py +++ b/addons/account_budget/report/analytic_account_budget_report.py @@ -78,11 +78,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 f8f812639b0..ba4da51d8c7 100644 --- a/addons/account_budget/report/budget_report.py +++ b/addons/account_budget/report/budget_report.py @@ -84,8 +84,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 @@ % + +