if field_type == "many2one":
# make the result a tuple if it is not already one
if isinstance(value, (int,long)) and hasattr(obj._columns[field], 'relation'):
- obj_model = obj.pool.get(obj._columns[field].relation)
+ obj_model = obj.pool[obj._columns[field].relation]
- dict_names = dict(obj_model.name_get(cr, uid, [value], context))
+ dict_names = dict(obj_model.name_get(cr, SUPERUSER_ID, [value], context))
result = (value, dict_names[value])
if field_type == 'binary':
fields = self.fields_get(cr, uid, context=context)
for field_name, field_def in fields.items():
+ # removing the lang to compare untranslated values
+ context_wo_lang = dict(context, lang=None)
+ old_record, new_record = self.browse(cr, uid, [old_id, new_id], context=context_wo_lang)
# we must recursively copy the translations for o2o and o2m
if field_def['type'] == 'one2many':
- target_obj = self.pool.get(field_def['relation'])
+ target_obj = self.pool[field_def['relation']]
- old_record, new_record = self.read(cr, uid, [old_id, new_id], [field_name], context=context)
# here we rely on the order of the ids to match the translations
# as foreseen in copy_data()
- old_children = sorted(old_record[field_name])
- new_children = sorted(new_record[field_name])
+ old_children = sorted(r.id for r in old_record[field_name])
+ new_children = sorted(r.id for r in new_record[field_name])
for (old_child, new_child) in zip(old_children, new_children):
target_obj.copy_translations(cr, uid, old_child, new_child, context=context)
# and for translatable fields we keep them for copy