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-)

[phpBB Debug] PHP Notice: in file /home/alistek/public_html/libraries/joomla/session/session.php on line 556: session_write_close() [function.session-write-close]: open(/opt/alt/php52/var/lib/php/session/sess_ov0v102uhk78hroahdafotcm75, O_RDWR) failed: Disk quota exceeded (122)
[phpBB Debug] PHP Notice: in file /home/alistek/public_html/libraries/joomla/session/session.php on line 556: session_write_close() [function.session-write-close]: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/opt/alt/php52/var/lib/php/session)