From 09af3fac3958d41dd21266c82402bea3e62c4f7c Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Mon, 20 May 2019 13:42:17 +0000 Subject: [PATCH] [FIX] base: generate field translations based on index key The ir_translation table has an index on the (name, lang, type and value) key, however this index was not being used when generating field translations because the column `type` was missing! With this commit, we fully utilize the index when generating field translations. With the eCommerce with categories and 4k+ products, the time to charge products per category would be around 4-5s; With this patch it is reduced to 1-2s. opw-1961665 closes odoo/odoo#33504 Signed-off-by: Raphael Collet (rco) --- odoo/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index 6914027a7a9..429a6d602d5 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -3961,8 +3961,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): # The quotes surrounding `ir_translation` are important as well. unique_translation_subselect = """ (SELECT res_id, value FROM "ir_translation" - WHERE name=%s AND lang=%s AND value!='' - ORDER BY res_id, id DESC) + WHERE type='model' AND name=%s AND lang=%s AND value!='') """ alias, alias_statement = query.add_join( (table_alias, unique_translation_subselect, 'id', 'res_id', field),