Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
420 Widoki

Hi everyone,

I am trying to connect to the demo database of Odoo using xmlrpc.client in python but I get 404 errors everytime.

I tried this with python 3.10 and 3.13 on a Mac, and 3.13 on windows and I always get the same results.

I also have tried different networks (work, home and hotspot).


Note sure what I am doing wrong here. This is just the example code from the documentation. 

I have tried searching for this issue, but there is nobody else with this issue apparently.


import xmlrpc.client

info = xmlrpc.client.ServerProxy("https://demo.odoo.com/start").start()

url, db, username, password = info["host"], info["database"], info["user"], info["password"]

common = xmlrpc.client.ServerProxy("{}/xmlrpc/2/common".format(url))

common.version()

 

Traceback (most recent call last):

  File "<python-input-0>", line 5, in <module>

    common.version()

    ~~~~~~~~~~~~~~^^

  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xmlrpc/client.py", line 1096, in __call__

    return self.__send(self.__name, args)

           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xmlrpc/client.py", line 1435, in __request

    response = self.__transport.request(

        self.__host,

    ...<2 lines>...

        verbose=self.__verbose

        )

  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xmlrpc/client.py", line 1140, in request

    return self.single_request(host, handler, request_body, verbose)

           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/homebrew/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xmlrpc/client.py", line 1170, in single_request

    raise ProtocolError(

    ...<3 lines>...

        )

xmlrpc.client.ProtocolError: <ProtocolError for demo3.odoo.com/xmlrpc/2/common: 404 NOT FOUND>

Awatar
Odrzuć
Autor

Hi,

Thank you for your reply @Cybrosys 

The code I posted, is letter for letter exactly what is published on those pages.

See "test database"and "logging in" (I can't post links because of low karma).

So I still don't know what I am doing wrong here

Najlepsza odpowiedź

Hi,


You can go through the official documentation of Odoo. Please refer to the link below.

https://www.odoo.com/documentation/17.0/th/developer/reference/external_api.html


Hope it helps

Awatar
Odrzuć
Najlepsza odpowiedź

Hii,


import xmlrpc.client


url = "http://localhost:8069"       # or https://yourdomain.odoo.com if hosted

db = "your_database_name"           # your actual database name

username = "admin"                  # your Odoo username

password = "admin"                  # your Odoo password



common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common")

uid = common.authenticate(db, username, password, {})

print("Authenticated UID:", uid)


if not uid:

    print("Authentication failed. Check credentials.")

    exit()



models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")


# Example: Read the first 5 partners

partner_ids = models.execute_kw(

    db, uid, password,

    'res.partner', 'search',

    [[]],  # empty domain = all records

    {'limit': 5}

)


partners = models.execute_kw(

    db, uid, password,

    'res.partner', 'read',

    [partner_ids],

    {'fields': ['name', 'email']}

)


print("First 5 partners:")

for partner in partners:

    print(f"  {partner['name']} - {partner.get('email', 'No email')}")


please try this code as your work and one example is also there 
i hope it is use full

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 23
12864
0
cze 20
61
1
maj 24
2589
1
lis 22
3036
3
cze 22
6219