diff options
| author | Jeremy Kersten <jke@odoo.com> | 2020-03-13 15:16:40 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2020-03-19 15:37:47 +0000 |
| commit | 4c403934903b68afb08e87ac571b6777042e5a7f (patch) | |
| tree | d18c5b90847137099983849abcca732832426df8 /addons/http_routing | |
| parent | c2142a34f73cb8329e8d214596484bd9a581b3e6 (diff) | |
[FIX] website: perf - translation - avoid query to find what we know
Before this commit, each module override _get_translation_frontend_modules_domain
from ir.http to add its own translation in website if needed and that module
is not starting by website_. Updating the domain from the super() call.
Since we know in most of the case the name, it is useless to do a:
select name from module where name = 'name1' or name = 'name2'...
Now we support a new override of _get_translation_frontend_modules_name that will
allow to add the known module name directly in the list instead to make a search.
In case nobody override _get_translation_frontend_modules_domain, we don't need to
make an extra rpc to find the module.
Related to #47257
task-2211013
X-original-commit: 0dc54814161ab55c34dd2242f65dea23d19fdfca
Diffstat (limited to 'addons/http_routing')
| -rw-r--r-- | addons/http_routing/models/ir_http.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index 4f441b2079a..ae3ca509b73 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -313,17 +313,28 @@ class IrHttp(models.AbstractModel): @api.model def get_translation_frontend_modules(self): Modules = request.env['ir.module.module'].sudo() - domain = self._get_translation_frontend_modules_domain() - return Modules.search( - expression.AND([domain, [('state', '=', 'installed')]]) - ).mapped('name') + extra_modules_domain = self._get_translation_frontend_modules_domain() + extra_modules_name = self._get_translation_frontend_modules_name() + if extra_modules_domain: + new = Modules.search( + expression.AND([extra_modules_domain, [('state', '=', 'installed')]]) + ).mapped('name') + extra_modules_name += new + return extra_modules_name @classmethod def _get_translation_frontend_modules_domain(cls): """ Return a domain to list the domain adding web-translations and dynamic resources that may be used frontend views """ - return [('name', '=', 'web')] + return [] + + @classmethod + def _get_translation_frontend_modules_name(cls): + """ Return a list of module name where web-translations and + dynamic resources may be used in frontend views + """ + return ['web'] bots = "bot|crawl|slurp|spider|curl|wget|facebookexternalhit".split("|") |
