[FIX] base: update translations should not duplicate the terms

When a translated term is modified (e.g. content of an email.template),
reloading the translations of the module (e.g. when updating the module) used to
recreate a new, duplicare translation for the modified term (instead of ignoring
the existing one).

This was due to the fact the matching expression (find_expr), when loading
translations, used the field 'src' (source term) as criteria for (almost) all
ir.translation records.

While this is true for type 'code' or 'selection', this is not true for 'model'
where the source content may have been changed.
In case of translation of type 'model', matching on the name and res_id should be
enough for the matching expression and then, avoid creating duplicated
translations.

Note: this patch must NOT be present in 9.0 due to the xml_translate
attribute that splits an xml content into small parts.

opw 654031
This commit is contained in:
Martin Trigaux 2015-11-18 16:56:52 +01:00
parent a70287d42c
commit 1f07b9429c
1 changed files with 7 additions and 5 deletions

View File

@ -125,10 +125,12 @@ class ir_translation_import_cursor(object):
AND irt.type = ti.type
AND irt.module = ti.module
AND irt.name = ti.name
AND (ti.type IN ('field', 'help') OR irt.src = ti.src)
AND ( ti.type NOT IN ('model', 'view')
OR (ti.type = 'model' AND ti.res_id = irt.res_id)
OR (ti.type = 'view' AND (irt.res_id IS NULL OR ti.res_id = irt.res_id))
AND ( -- 8.0 only where unicity is assured on translations of 'model'
(ti.type = 'model' AND ti.res_id = irt.res_id)
OR (ti.type = 'view' AND (irt.res_id IS NULL OR ti.res_id = irt.res_id) AND irt.src = ti.src)
OR (ti.type = 'field')
OR (ti.type = 'help')
OR (ti.type NOT IN ('model', 'view', 'field', 'help') AND irt.src = ti.src)
)
"""