Don't override module value when creating translation if it is set for
issue569
This commit is contained in:
1 parent
aa1629b7e1
commit
e9d563f0be
1 file changed
+25
-24
+25
-24
@@ -301,30 +301,31 @@ class Translation(OSV, Cacheable):
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
self.clear(cursor)
|
||||
self.fields_view_get(cursor.dbname)
|
||||
if vals.get('type', '') in ('odt', 'view', 'wizard_button',
|
||||
'selection', 'error'):
|
||||
cursor.execute('SELECT module FROM ir_translation ' \
|
||||
'WHERE name = %s ' \
|
||||
'AND res_id = %s ' \
|
||||
'AND lang = %s ' \
|
||||
'AND type = %s ' \
|
||||
'AND src = %s ',
|
||||
(vals.get('name', ''), vals.get('res_id', 0), 'en_US',
|
||||
vals.get('type', ''), vals.get('src', '')))
|
||||
if cursor.rowcount:
|
||||
vals = vals.copy()
|
||||
vals['module'] = cursor.fetchone()[0]
|
||||
else:
|
||||
cursor.execute('SELECT module, src FROM ir_translation ' \
|
||||
'WHERE name = %s ' \
|
||||
'AND res_id = %s ' \
|
||||
'AND lang = %s ' \
|
||||
'AND type = %s',
|
||||
(vals.get('name', ''), vals.get('res_id', 0), 'en_US',
|
||||
vals.get('type', '')))
|
||||
if cursor.rowcount:
|
||||
vals = vals.copy()
|
||||
vals['module'], vals['src'] = cursor.fetchone()
|
||||
if not vals.get('module'):
|
||||
if vals.get('type', '') in ('odt', 'view', 'wizard_button',
|
||||
'selection', 'error'):
|
||||
cursor.execute('SELECT module FROM ir_translation ' \
|
||||
'WHERE name = %s ' \
|
||||
'AND res_id = %s ' \
|
||||
'AND lang = %s ' \
|
||||
'AND type = %s ' \
|
||||
'AND src = %s ',
|
||||
(vals.get('name', ''), vals.get('res_id', 0), 'en_US',
|
||||
vals.get('type', ''), vals.get('src', '')))
|
||||
if cursor.rowcount:
|
||||
vals = vals.copy()
|
||||
vals['module'] = cursor.fetchone()[0]
|
||||
else:
|
||||
cursor.execute('SELECT module, src FROM ir_translation ' \
|
||||
'WHERE name = %s ' \
|
||||
'AND res_id = %s ' \
|
||||
'AND lang = %s ' \
|
||||
'AND type = %s',
|
||||
(vals.get('name', ''), vals.get('res_id', 0), 'en_US',
|
||||
vals.get('type', '')))
|
||||
if cursor.rowcount:
|
||||
vals = vals.copy()
|
||||
vals['module'], vals['src'] = cursor.fetchone()
|
||||
return super(Translation, self).create(cursor, user, vals,
|
||||
context=context)
|
||||
|
||||
|
||||
Reference in new issue
Block a user