From a57b214c7d69adaa0d776432cfb686d084cbd3b8 Mon Sep 17 00:00:00 2001 From: "Jordan D. (Joda)" Date: Tue, 10 Jan 2023 08:29:48 +0000 Subject: [PATCH] [FIX] tools: add SQL comparaison to fix module translation When installing both documents and fleet and then, add a translation to the database. Both fleet and document will be translated the same way. This is due to the fact that both of them share a lot of similar value inside of the PSQL database. opw-3120320 closes odoo/odoo#109700 X-original-commit: fff53f845398ee0f8632cf7cb392f108388f3dc4 Signed-off-by: Raphael Collet Signed-off-by: Nicolas Lempereur (nle) --- odoo/tools/translate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index f7921d42bfa..afcad285d07 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -1370,7 +1370,7 @@ class TranslationImporter: # [xmlid, translations, xmlid, translations, ...] params = [] for xmlid, translations in sub_field_dictionary: - params.extend([xmlid.split('.')[-1], Json(translations)]) + params.extend([*xmlid.split('.'), Json(translations)]) if not force_overwrite: value_query = f"""CASE WHEN {overwrite} IS TRUE AND imd.noupdate IS FALSE THEN m."{field_name}" || t.value @@ -1381,10 +1381,10 @@ class TranslationImporter: UPDATE "{model_table}" AS m SET "{field_name}" = {value_query} FROM ( - VALUES {', '.join(['(%s, %s::jsonb)'] * (len(params) // 2))} - ) AS t(imd_name, value) + VALUES {', '.join(['(%s, %s, %s::jsonb)'] * (len(params) // 3))} + ) AS t(imd_module, imd_name, value) JOIN "ir_model_data" AS imd - ON imd."model" = '{model_name}' AND imd.name = t.imd_name + ON imd."model" = '{model_name}' AND imd.name = t.imd_name AND imd.module = t.imd_module WHERE imd."res_id" = m."id" """, params)