tinyerp / odooly

Python library and CLI to interact with Odoo and OpenERP.
https://odooly.rtfd.io/
Other
60 stars 33 forks source link

Does `env.cr` only work when on a local server? #6

Closed tmijail closed 4 years ago

tmijail commented 5 years ago

When I execute

from odooly import *
cl = Client.from_config('testing')
env = cl.env

env.cr

I get the following error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-48-c4e964fa0ffc> in <module>
----> 1 env.cr

~/.local/lib/python3.7/site-packages/odooly.py in cr(self)
    611         return self.__dict__.get('cr') or _memoize(
    612             self, 'cr', self.registry.db.cursor()
--> 613             if self.client.version_info < 8.0 else self.registry.cursor())
    614 
    615     @property

~/.local/lib/python3.7/site-packages/odooly.py in registry(self)
    616     def registry(self):
    617         """Return the environment's registry."""
--> 618         return self.client._server._get_pool(self.db_name)
    619 
    620     def __call__(self, user=None, password=None, context=None):

AttributeError: 'str' object has no attribute '_get_pool'

Looking at the Odooly source, it seems to me that env.registry only exists if env.client._server was set with start_odoo_services. Is there a way to get a cursor on a remote server? Or more to the point, can I use Odooly to execute an SQL query on a remote server?

Thanks.

florentx commented 5 years ago

The cursor stuff is only a helper in local mode, there's no way to grab a cursor remotely through RPC. Same for SQL query on the server. This would be a major security issue if Odoo allow such remote access to the SQL interface.