Skip to content
Snippets Groups Projects
Commit cf66983f authored by Goffin Simon's avatar Goffin Simon
Browse files

[FIX] base: Language translation import issue

When importing translations with a csv, the state of the translations was
always set to "To translate" even if the state was "Translated"
due to function _inverse_source.

PS: Making self.source when self is considered as record set could lead to an error.
The return in this function was not needed.
In old API this function was called just for one record.
So this function expect only one record at each call.

opw:747877
parent 9771056c
Branches
Tags
No related merge requests found
......@@ -240,18 +240,19 @@ class IrTranslation(models.Model):
''' When changing source term of a translation, change its value in db
for the associated object, and the src field.
'''
for record in self:
if record.type == 'model':
model_name, field_name = record.name.split(',')
model = self.env[model_name]
field = model._fields[field_name]
if not callable(field.translate):
# Make a context without language information, because we want
# to write on the value stored in db and not on the one
# associated with the current language. Also not removing lang
# from context trigger an error when lang is different.
model.browse(record.res_id).with_context(lang=None).write({field_name: record.source})
return self.write({'src': self.source})
self.ensure_one()
if self.type == 'model':
model_name, field_name = self.name.split(',')
model = self.env[model_name]
field = model._fields[field_name]
if not callable(field.translate):
# Make a context without language information, because we want
# to write on the value stored in db and not on the one
# associated with the current language. Also not removing lang
# from context trigger an error when lang is different.
model.browse(self.res_id).with_context(lang=None).write({field_name: self.source})
if self.src != self.source:
self.write({'src': self.source})
def _search_source(self, operator, value):
''' the source term is stored on 'src' field '''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment