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

Loading a Model Object with data loaded from an API

By
P Mittal
on 5/31/13, 12:32 AM 1,473 views

Unlike adding fixture data in the form of xml_data files, I want to get the load the data from an API location. How should I do that? This is what I am thinking of (please read the code comments too):

class Bank(osv.Model):

"""This class defines a Bank Object"""

_name = 'obp.bank'
_description = 'OBP Bank'
_order = 'name'

_columns = {
    'full_name' : fields.char('Bank name'),
    'logo' : fields.char('Bank Logo'),
    'website' : fields.char('Bank Website'),
    'id' : fields.char('Bank ID'),
    'short_name' : fields.char('Bank Short Name'),

def get_bank_data(): # What should I write here instead?? __init__.py?
    # The code here gets the data from the API into a python dictionary
    # from which I want to load it into this Bank Database table.

What will be the best way to do this?

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

Hi,
if you haven't done so yet, I would suggest you to create a list of lists with your data fetched from an external API call. See Bulk Import doc.
And then use the load() method on your object to create entries. See method signature here

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: 5/31/13, 12:32 AM
Seen: 1473 times
Last updated: 3/16/15, 8:10 AM