Page 1 of 1

Problem with existing records

PostPosted: Tue Oct 25, 2011 3:10 pm
by qgerome
Hi,

When I try to migrate partners addresses from v5 to v6, I want to migrate the field country_id but it is not filled because of :
Code: Select all
Warning! Object "res.partner.address" have relation field 'country_id' which related to object "res.country", this field was not filled because related object's model is not added in Import Model list.


Since the countries are created automatically, I can't delete them and import them with a new model mapping. Is it a way to tell the system that it's already migrated and use the field value to search for the adequate country ?

Regards,

Quentin.

Re: Problem with existing records

PostPosted: Wed Oct 26, 2011 5:46 pm
by ruslans
For this case you must be use field value constructor in the mapping definition of this field. In the constructor editor write so like:
Code: Select all
if old_values['country_id']:
     code = read_old('res.country', old_values['country_id'][0], ['code'])['code']
     value = self.pool.get('res.country').search(cr, uid, [('code','=',code)])[0]

Re: Problem with existing records

PostPosted: Fri Oct 17, 2014 8:35 pm
by edward745
ruslans wrote:For this case you must be use field value constructor in the mapping definition of this field. In the constructor editor write so like:
Code: Select all
if old_values['country_id']:
     code = read_old('res.country', old_values['country_id'][0], ['code'])['code']
     value = self.pool.get('res.country').search(cr, uid, [('code','=',code)])[0]

yeah rusians is right you to use this code to fix the problem 8-)