Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

why does orm load() method mark external ids as noupdate=False by default ?

By
Nicolas Clavier
on 6/21/13, 8:20 AM 1,781 views

Hi,
In the process of loading big amount of data into tables, I noticed that when restarting the server updating my custom module, the data previously entered was deleted from the database automatically !

I use the load() method and for each record I specified an xml_id (external id) so that running the same import twice would only update records. When looking at the the external ids created, I noticed that the noupdate field was automatically set to False.

Those records are therefore deleted when updating the module, as part of the module update protocol.

Can anyone help on how to intruct the load() method to forcecreate / set no update = True on the xml_ids of my newly created records ?

Doc reference:

0
Nicolas Clavier
On 6/21/13, 8:24 AM

As a temporary workaround I added the following to my import function: From the ids returned by the load() method, I search for corresponding ir_model_data entries, and update their 'noupdate' field to True.

res = partner_pool.load(cr, uid, field_names, partners, context=context)

if res['ids']:
    imd_pool = self.pool.get('ir.model.data')
    imd_ids  = imd_pool.search(cr, uid, [('res_id','in',res['ids']),('model','=','res.partner')], context=context)
    _logger.debug("Fixing external ids with no update = True on : %s" % imd_ids)
    if imd_ids:
        imd_pool.write(cr, uid, imd_ids, {'noupdate':True}, context=context)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/21/13, 8:20 AM
Seen: 1781 times
Last updated: 3/16/15, 8:10 AM