[FIX] base: avoid deleting translations
When updating a translation, the previous one is deleted and a new one is recreated (with no module and state). When the source module is updated, the previous term is inserted again to the lsit of terms. Instead of dropping and recreating terms during update, simply update the existing term and create one only if there were no previous translation. Fixes #4617
This commit is contained in:
parent
8f07f01783
commit
39d17c2580
|
@ -286,21 +286,31 @@ class ir_translation(osv.osv):
|
|||
def _set_ids(self, cr, uid, name, tt, lang, ids, value, src=None):
|
||||
self._get_ids.clear_cache(self)
|
||||
self.__get_source.clear_cache(self)
|
||||
|
||||
cr.execute('delete from ir_translation '
|
||||
original_module = self.pool[name.split(',')[0]]._original_module
|
||||
cr.execute('update ir_translation '
|
||||
'set value=%s '
|
||||
' , src=%s '
|
||||
' , state=%s '
|
||||
'where lang=%s '
|
||||
'and type=%s '
|
||||
'and name=%s '
|
||||
'and res_id IN %s',
|
||||
(lang,tt,name,tuple(ids),))
|
||||
for id in ids:
|
||||
'and module=%s '
|
||||
'and res_id IN %s '
|
||||
'returning res_id',
|
||||
(value,src,'translated',lang,tt,name,original_module,tuple(ids),))
|
||||
|
||||
existing_ids = [x[0] for x in cr.fetchall()]
|
||||
|
||||
for id in list(set(ids) - set(existing_ids)):
|
||||
self.create(cr, uid, {
|
||||
'lang':lang,
|
||||
'type':tt,
|
||||
'name':name,
|
||||
'res_id':id,
|
||||
'module':original_module,
|
||||
'value':value,
|
||||
'src':src,
|
||||
'state':'translated'
|
||||
})
|
||||
return len(ids)
|
||||
|
||||
|
|
Loading…
Reference in New Issue