=== modified file 'bin/osv/orm.py' --- bin/osv/orm.py 2010-06-18 09:23:00 +0000 +++ bin/osv/orm.py 2010-06-21 07:52:27 +0000 @@ -2237,15 +2237,23 @@ type = self._inherit_fields[key][2]._type else: continue - if type == 'reference' and v: - model,ref_id = v.split(',') - table = self.pool.get(model)._table - cr.execute('select id from "%s" where id=%%s' % (table,), (ref_id,)) - id_exist = cr.fetchone() - if not id_exist: - query = 'UPDATE "%s" SET "%s"=NULL WHERE "%s"=%%s' % (self._table, key, key) - cr.execute(query, (v,)) - r[key] = '' + + if v: + if type == 'many2one': + if (key in self._columns.keys() and self._columns[key].__class__._type =='function' and self._columns[key].store): + r[key] = self.pool.get(self._columns[key].relation).name_get(cr, user, [v], context=context)[0] + if (key in self._inherit_fields.keys() and self._inherit_fields[key][2].__class__._type =='function' and self._inherit_fields[key][2].store): + r[key] = self.pool.get(self._inherit_fields[key][2].relation).name_get(cr, user, [v], context=context)[0] + + elif type == 'reference': + model,ref_id = v.split(',') + table = self.pool.get(model)._table + cr.execute('select id from "%s" where id=%%s' % (table,), (ref_id,)) + id_exist = cr.fetchone() + if not id_exist: + query = 'UPDATE "%s" SET "%s"=NULL WHERE "%s"=%%s' % (self._table, key, key) + cr.execute(query, (v,)) + r[key] = '' if isinstance(ids, (int, long)): return result and result[0] or False