[MERGE] forward port of branch 7.0 up to revid 5148 mat@openerp.com-20131125125008...
authorChristophe Simonis <chs@openerp.com>
Mon, 25 Nov 2013 15:10:17 +0000 (16:10 +0100)
committerChristophe Simonis <chs@openerp.com>
Mon, 25 Nov 2013 15:10:17 +0000 (16:10 +0100)
bzr revid: chs@openerp.com-20131125151017-lmj53bxg1pfrr4a7

1  2 
openerp/osv/fields.py
openerp/osv/orm.py
openerp/tools/misc.py

@@@ -1146,8 -1115,8 +1146,8 @@@ class function(_column)
          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':
@@@ -5069,14 -4991,16 +5066,16 @@@ class BaseModel(object)
          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
Simple merge