Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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-
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.
(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?
You can call OpenERP API from python prompt. Use xmlrpclib library of python and call API.
import xmlrpclib s_str = 'http://localhost:8069/xmlrpc/object' sock = xmlrpclib.ServerProxy(s_str)
prod_ids = sock.execute(DBNAME, USERID, PASSWD, 'product.product','search', )
This way you can call other API like create, read, write, unlink and also method of object from python prompt.
Email : email@example.com
Skype : acespritech
Blog : acespritechblog.wordpress.com
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.
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/31/13, 11:12 PM|
|Seen: 2626 times|
|Last updated: 3/16/15, 8:10 AM|