From 021c1a26c55c9f9b9be6269c64d06c350ad1f5fe Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 2 Mar 2015 14:26:39 +0100 Subject: [PATCH 01/24] [IMP] fields: improve performance when reading many2one fields on records Improve the performance of `name_get()` on many2one field values by making sure that the records on which `name_get` is invoked are prefetched in cache. This is not automatic, because `name_get` is invoked on records in another environment (sudo mode): the prefetching in the original environment should be reproduced in the other environment. --- openerp/fields.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openerp/fields.py b/openerp/fields.py index b78f5b330d2..2688e7e56ca 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -1482,7 +1482,11 @@ class Many2one(_Relational): # many2one field value (id and name) depends on the current record's # access rights, and not the value's access rights. try: - return value.sudo().name_get()[0] + value_sudo = value.sudo() + # performance trick: make sure that all records of the same + # model as value in value.env will be prefetched in value_sudo.env + value_sudo.env.prefetch[value._name].update(value.env.prefetch[value._name]) + return value_sudo.name_get()[0] except MissingError: # Should not happen, unless the foreign key is missing. return False From c40d5065faaf7afcb0552b23af66f5cb3f7dc1bc Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 3 Mar 2015 09:51:08 +0100 Subject: [PATCH 02/24] [FIX] purchase: get taxes when create rfq from bid When creating a request for quotation from a call for bids, the suppliers taxes where not present in the quotation. Since a product `taxes_id` field is a many2many, the unused triplets syntax caused the issue. fixes #5307 --- addons/purchase_requisition/purchase_requisition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 79c14e4037a..f1af1345a52 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -170,7 +170,7 @@ class purchase_requisition(osv.osv): 'order_id': purchase_id, 'product_id': product.id, 'account_analytic_id': requisition_line.account_analytic_id.id, - 'taxes_id': [(6, 0, vals.get('taxes_ids', []))], + 'taxes_id': [(6, 0, vals.get('taxes_id', []))], }) return vals From 752e21a633be22e30cb8ff9d63ad2ee656ff6b71 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 3 Mar 2015 11:51:50 +0100 Subject: [PATCH 03/24] [FIX] py.js: arguments dispatching in PY_call When providing an args of ``null`` (or ``undefined``) and a non-empty kwargs, the kwargs would be removed/ignored. While explicitly providing a null args is not necessary, it's perfectly valid. --- addons/web/static/lib/py.js/lib/py.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web/static/lib/py.js/lib/py.js b/addons/web/static/lib/py.js/lib/py.js index 2c738dc95d1..ed5657c8f3b 100644 --- a/addons/web/static/lib/py.js/lib/py.js +++ b/addons/web/static/lib/py.js/lib/py.js @@ -547,11 +547,13 @@ var py = {}; }; py.PY_call = function (callable, args, kwargs) { if (!args) { - args = []; kwargs = {}; - } else if (typeof args === 'object' && !(args instanceof Array)) { + args = []; + } + if (typeof args === 'object' && !(args instanceof Array)) { kwargs = args; args = []; - } else if (!kwargs) { + } + if (!kwargs) { kwargs = {}; } if (callable.__is_type) { From adf5b5e0e85d21128a96cabbd312031c0bb44fae Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 3 Mar 2015 11:54:12 +0100 Subject: [PATCH 04/24] [FIX] tests: overflow on test page body inherited from main CSS, would prevent from scrolling body and thus from seeing all the test cases and test case contents (e.g. error messages and stack traces) --- addons/web/views/webclient_templates.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index e16e97d56ec..a066e1e4a24 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -332,6 +332,9 @@ +