From 3b3c9c687d013200db49484d2fbb4a8b45f7a52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20=40PlanetaTIC?= Date: Thu, 16 Jan 2020 11:55:36 +0100 Subject: [PATCH] [FIX] base: Fix issues importing translations - Previous commit breaks import (from ONLY needed in where not exists) - Avoid duplicates in import (select DISTINCT needed in insert into) --- odoo/addons/base/ir/ir_translation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/odoo/addons/base/ir/ir_translation.py b/odoo/addons/base/ir/ir_translation.py index 407888eab2358..233926ea97845 100644 --- a/odoo/addons/base/ir/ir_translation.py +++ b/odoo/addons/base/ir/ir_translation.py @@ -161,12 +161,14 @@ def finish(self): # Step 3: insert new translations cr.execute(""" INSERT INTO %(_model_table)s(name, lang, res_id, src, type, value, module, state, comments) - SELECT name, lang, res_id, src, type, value, module, state, comments + SELECT DISTINCT ON (type, name, lang, res_id, md5(src)) + name, lang, res_id, src, type, value, module, state, comments FROM %(_table)s AS ti WHERE NOT EXISTS(SELECT 1 FROM ONLY %(_model_table)s AS irt WHERE %(find_expr)s) AND - NOT EXISTS(SELECT 1 FROM %(_model_table)s AS tj - WHERE (ti.type, ti.name, ti.lang, ti.res_id, md5(ti.src)) = - (tj.type, tj.name, tj.lang, tj.res_id, md5(tj.src))); + NOT EXISTS(SELECT 1 FROM ONLY %(_model_table)s AS irt + WHERE (irt.type, irt.name, irt.lang, irt.res_id, md5(irt.src)) = + (ti.type, ti.name, ti.lang, ti.res_id, md5(ti.src))) + ORDER BY type, name, lang, res_id, md5(src), id DESC; """ % dict(_model_table=self._model_table, _table=self._table, find_expr=find_expr), (tuple(src_relevant_fields), tuple(src_relevant_fields)))