Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] base: Fix issues importing translations #7

Open
wants to merge 1 commit into
base: 10.0-odoo-hugely_degraded_performance_in_translation_subquery
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions odoo/addons/base/ir/ir_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down