[FIX] base: avoid duplicated translations when possible

When modifying a translatable record, we try to keep close translations
However, we do not need to do it if there is already a translation for
the matched term.
This commit is contained in:
Christophe Simonis
2018-03-23 15:40:49 +01:00
parent 2c5fe07fc7
commit f36f1ceccf
+6 -1
View File
@@ -479,13 +479,18 @@ class ir_translation(osv.osv):
continue
# remap existing translations on terms when possible
trans_src = record_trans.mapped('src')
for trans in record_trans:
if trans.src == trans.value:
discarded += trans
elif trans.src not in terms:
matches = get_close_matches(trans.src, terms, 1, 0.9)
if matches:
trans.write({'src': matches[0], 'state': trans.state})
if matches[0] in trans_src:
# there is already a translation for this term; discard this one
discarded += trans
else:
trans.write({'src': matches[0], 'state': trans.state})
else:
outdated += trans