diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py index 875f8756c2..36ed444a01 100644 --- a/trytond/ir/translation.py +++ b/trytond/ir/translation.py @@ -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)