OCA / odoorpc

Python module to pilot your Odoo servers through JSON-RPC.
http://pythonhosted.org/OdooRPC/
GNU Lesser General Public License v3.0
237 stars 125 forks source link

Error with connecting to some Odoo instances. #9

Closed sebalix closed 5 years ago

sebalix commented 7 years ago

From @acidjunk on April 26, 2017 22:42

I used OdooRPC in the past: Thanks for a great piece of software :)

Recently I wanted to use it to connect to a Odoo 9 that is behind a Nginx reverse proxy. When I connect to an Odoo running on localhost everything works fine. (protocol JSONRPC, port 8069)

When I try to connect to the production version (JSONRPC+SSL) I receive the following error: odoorpc.error.RPCError: request not bound to a database

I'm sure that I used a database that was listed when I executed:

odoo = odoorpc.ODOO('rene-dohmen.odoo.com', protocol='jsonrpc+ssl', port=443)
print(odoo.db.list())

then tried to do the login: odoo.login('the_db', login='admin', password='password')

To rule out Odoo misconfiguration I wrote a simple tester: https://gist.github.com/acidjunk/662bad6c216811ca6b4eb119a9b34e8d

That works as expected with the local odoo instance and with the production.

Am I doing something wrong?

Copied from original issue: osiell/odoorpc#45

sebalix commented 7 years ago

Hi,

This is strange, you are doing it well. Which version do you use? We are using OdooRPC 0.5.1 to sync data between Odoo 8.0 (backoffice) with a Odoo 9.0 (CMS/e-commerce). The Odoo 9.0 instance is behind an Apache reverse proxy with SSL/TLS, all is working fine for 1 year. I should test it against the new release 0.6.0.

sebalix commented 7 years ago

Also, is the 9.0 instance hosting multiple databases?

sebalix commented 7 years ago

From @acidjunk on April 27, 2017 11:13

Odoo version 9.0e Our acceptance env has multiple db's: that gives request not bound to a database Our production env has one DB: that gives: urllib2.HTTPError: HTTP Error 403: Forbidden (my own test script works fine one both of them)

The errors are already shown before the login.

Is there an easy way to come up with more debug info? Will try with an 0.5.1 in a minute.

sebalix commented 7 years ago

From @acidjunk on April 27, 2017 11:55

Same behaviour with OdooRPC 0.5.1

sebalix commented 7 years ago

From @acidjunk on April 28, 2017 7:54

It also seems to fail when using an free Odoo instance provided by odoo.com. I can provide you with some credentials for that?

sebalix commented 7 years ago

Yes, it will help me to track the issue, if it doesn't bother you. You can find my email in the Git log. I also test myself some connections on Odoo 10.0c behind an Apache reverse proxy with SSL, without any problem. I do not know NGinx very well, but can you post your reverse proxy configuration too? Do you use the standard authentication method on Odoo or another one (LDAP, OAuth...)?

sebalix commented 7 years ago

From @acidjunk on April 28, 2017 10:32

I traced it a bit, and made some progress: Listing the DB's seems not possible in all occasions. Listing version number is also not always possible; in that case the constructor of ODOO will fail before doing anything. (I commented it in my fork, to get past the constructor.)

The login of the lib uses /web/session/authenticate to handle the login. This will not work on our own Odoo versions but it works on the odoo.com version. I'm trying to refactor this so it uses:

data = self.json(
    '/jsonrpc',
    {'service': 'common', 'method': 'login', 'args': [db, login, password]})

That works on both of our servers, but I need to work on the retrieval of the context also so Environment can be used. I hard coded the context for now...

Creds for rene-dohmen.odoo.com are on the way, but I doubt much use of it as my problem seems related to restrictions on /web/session which isn't the case with classic odoo from odoo.com.

sebalix commented 7 years ago

Regarding the version number, you can set the version parameter for odoorpc.ODOO to prevent an extra RPC request on /web/webclient/version_info. The version number is required by OdooRPC to adapt its RPC queries depending on the server, if it is not supplied by the user it will try to guess it automatically.

sebalix commented 7 years ago

From @acidjunk on May 6, 2017 13:42

When I provide/force the version number I receive the same error: odoorpc.error.RPCError: request not bound to a database

When I just use jsronrpclib in python it all works just fine. The login as used in my fork, sort of works, would be nice if I could use your library; it's a lot easier when updating/creating stuff.

sebalix commented 7 years ago

@acidjunk a possible solution to your problem:

import odoorpc

class MyOdoo(odoorpc.ODOO):
    def login(self, db, login='admin', password='admin'):
        # TODO handle the login the way you want

odoo = MyOdoo(...)
odoo.login('dbname', 'login', 'password')
mlaitinen commented 5 years ago

This could be caused by some custom addons that call self.env during the dispatch. At least that was the case for me.

pedrobaeza commented 5 years ago

We don't have more feedback for this, so closing.