Problem with existing records

Problem with existing records

Postby qgerome » Tue Oct 25, 2011 3:10 pm

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.
qgerome
 
Posts: 14
Joined: Mon Jan 10, 2011 5:29 pm

Re: Problem with existing records

Postby ruslans » Wed Oct 26, 2011 5:46 pm

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]
ruslans
 
Posts: 15
Joined: Mon Jun 15, 2009 11:09 am

Re: Problem with existing records

Postby edward745 » Fri Oct 17, 2014 8:35 pm

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-)
aaaaaa
edward745
 
Posts: 1
Joined: Fri Oct 17, 2014 8:33 pm


Return to Server Data Migration

Copyright © 2001 Alistek Ltd., ALL RIGHTS RESERVED