From 617ba2887af55fc173b577a617cea64fa188fa93 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 24 Apr 2019 13:01:10 +0000 Subject: [PATCH] [IMP] base: avoid unnecessary exists in Contact HTML formatter Protactively checking exists() seems unnecessary, it's likely that the widget would be called on an empty recordset but seems very unlikely that it'll be called on a missing record. The commit which added the exists() call performs significant refactoring/rewrite and doesn't explain why this exists() call would be useful. Since exists is not cached and qweb field converters are not batched, saves a large number of queries when formatting a series of addresses e.g. with 99 hr.job, /jobs goes from ~170 queries and ~100ms spent in SQL to ~70 queries and ~60ms spent in SQL. Though the total performance improvement is very limited as even with odoo/odoo#32985 the endpoint takes ~700ms (with the aforementioned 99 hr.job visible to the current user). closes odoo/odoo#32986 Signed-off-by: Xavier Morel (xmo) --- odoo/addons/base/models/ir_qweb_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_qweb_fields.py b/odoo/addons/base/models/ir_qweb_fields.py index 1220b51a7c6..09d83b1ea57 100644 --- a/odoo/addons/base/models/ir_qweb_fields.py +++ b/odoo/addons/base/models/ir_qweb_fields.py @@ -637,7 +637,7 @@ class Contact(models.AbstractModel): @api.model def value_to_html(self, value, options): - if not value.exists(): + if not value: return False opf = options and options.get('fields') or ["name", "address", "phone", "mobile", "email"]