[IMP] base: optimize fields_get() in NameManager

`NameManager`'s validation passes should not be language-dependent.
Fetching translated model and view information thus incurs additional
costs for no reason.  Ensure translations are never enabled for
`NameManager`'s work.

In our benchmarch (py-spy with a rate of 200, render_all_view test-tag
and website_sale,mrp,contacts,crm,timesheet installated), 20% of the time
was spent in `NameManager.__init__` and thanks to this change it is
reduced to 11%. Queries count from 19995 to 17886. Total runtime from 24s
to 21.5s.

closes odoo/odoo#71419

Task: 2463632
Related: odoo/enterprise#18596
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
This commit is contained in:
Julien Castiaux
2021-06-11 17:09:05 +00:00
parent 50197d7337
commit e123aa2f30
+1 -1
View File
@@ -2020,7 +2020,7 @@ class NameManager:
self.mandatory_names_or_ids = dict()
self.available_names_or_ids = set()
self.validate = validate
self.Model = Model
self.Model = Model.with_context(lang=False)
self.fields_get = self.Model.fields_get()
def has_field(self, name, info=()):