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

efficient use of openerplib - xmlrpclib

By
Davy Cox
on 3/4/14, 12:47 PM 1,312 views

I'm synchronising my backend DB to OpenERP by using openerplib and xmlrpclib in a python script. By going line by line through my source database result (row), and then executing a write per line, it works how it should, but is extremely slow for thousand items:

   if row:

      for x in range(0, len(row)):

         partner_model = openerp_db.get_model('res.partner')
         partner_id = partner_model.search(['&', ('ref', '=', autoid), ('is_company', '=', True)])
         openerp_class.execute('res.partner', 'write', partner_id, {'ref': row[x][1], 'is_company': 'True',
                                                            'name': row[x][3], 'street': row[x][4],
                                                            'city': row[x][5], 'zip': row[x][6]}))

I assume this is because like this I make 1000x a call to get the model & partner_id which is unavoidable, but on top of that I also do 1000x an execute to save the new information to openERP which I hope can be done differently.

Would you have a recommendation or link with information on how to do this more efficiently? For example by doing only one execute but passing a list/dictionary of partner_id's and data information as a parameter?

Thank you in advance

You might like to do a quick test with oerplib, https://pypi.python.org/pypi/OERPLib to see if openerplib is the bottleneck.

Martin
on 3/4/14, 1:42 PM

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: 3/4/14, 12:47 PM
Seen: 1312 times
Last updated: 3/16/15, 8:10 AM