Skip to Content
Menu
This question has been flagged
2 Replies
8255 Views

I am wondering how can I use the OpenERP ORM interactively from the Python interpreter without having to use it within the module. Moreover, issuing a command (create/search/browse/...) is only allowed inside the class in the form something like this-

self.command

But I am not able to issue these commands on the object outside the class using model_name instead of self.

Example: I have a model called Bank. I want to create a bank from some python code somewhere else. Doing something this does NOT work.

Bank.create(...)

(cr, uid, etc are not available outside the class)

Things are not as simple as instantiating a Bank object like:

bank_obj = Bank(...values...)

and then issuing bank_obj.save() to save it in the database like it is in Django.

(My question is turning into..."Why does the OpenERP ORM have to be so complicated and non-pythonic? Why can't things be the Django way"), but thats not the main thing I want to ask in this question.

I want to understand how I could use the existing ORM well to do everything I could do with the Models in Django.

  • (1) Use the ORM interactively from the interpreter?
  • (2) Able to issue create, update, search, browse commands on the model, even outside the class where the model is defined?
Avatar
Discard
Best Answer

Hi ,

I know one that you can do the calling OpenERP framework the main purpose of OpenERP tools is for installing, configuring and managing instances and servers.

it can be found here https: // launchpad.net / oerptools

and it gives you some clues of how to use ORM interactively from the interpreter. and some clue of doing CRUD as well . Hope this is what you are looking for.

Avatar
Discard
Best Answer

Hi,

You can call OpenERP API from python prompt. Use xmlrpclib library of python and call API.

Example :

import xmlrpclib s_str = 'http://localhost:8069/xmlrpc/object' sock = xmlrpclib.ServerProxy(s_str)

prod_ids = sock.execute(DBNAME, USERID, PASSWD, 'product.product','search', [])

print prod_ids

This way you can call other API like create, read, write, unlink and also method of object from python prompt.

Email : info@acespritech.com
Skype : acespritech
Blog : acespritechblog.wordpress.com

Avatar
Discard
Related Posts Replies Views Activity
3
May 25
3186
1
Jul 24
1726
2
Jun 25
3774
0
Jun 21
2196
1
Aug 24
3202