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?