Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

API create_connection error (Name or service not known) to Odoo online server

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
api
1 Répondre
9244 Vues
Avatar
Fausto R.

Hello
I am following the suggestions from this post (https://www.odoo.com/forum/help-1/question/is-the-xml-rpc-api-available-on-openerp-online-915) and using the sample code from openerplib, as follow

import openerplib

DATABASE = 'mydb'
USERNAME = 'admin'
PASSWORD = 'mypass'
SERVER = 'https://' + DATABASE + '.my.openerp.com'

connection = openerplib.get_connection(hostname=SERVER, \
    database=DATABASE, login=USERNAME, password=PASSWORD)
user_model = connection.get_model("res.user")
print user_model
ids = user_model.search([("login", "=", "admin")])
user_info = user_model.read(ids[0], ["name"])
print user_info["name"]
# will print "Administrator"

But getting a connection error as detailed below

<openerplib.main.Model object at 0xb70376cc>
Traceback (most recent call last):
  File "odoo-t2.py", line 12, in <module>
    ids = user_model.search([("login", "=", "admin")])
  File "build/bdist.linux-i686/egg/openerplib/main.py", line 305, in proxy
  File "build/bdist.linux-i686/egg/openerplib/main.py", line 243, in check_login
  File "build/bdist.linux-i686/egg/openerplib/main.py", line 180, in proxy
  File "build/bdist.linux-i686/egg/openerplib/main.py", line 83, in send
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1292, in single_request
    self.send_content(h, request_body)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1439, in send_content
    connection.endheaders(request_body)
  File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 812, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 793, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

 

I have tried also with xmlrpclib and oerplib, with similar error results

This is the sample code using plain xmlrpclib (this is the one I'd like to see working !!!)

server = ServerProxy(SERVER + '/xmlrpc/common')
user_id = server.login(DATABASE, USERNAME, PASSWORD)

server = ServerProxy(SERVER + '/xmlrpc/object')
user_ids = server.execute(DATABASE, user_id, PASSWORD,
    'res.users', 'search', []
)

users = server.execute(DATABASE, user_id, PASSWORD,
    'res.users', 'read', user_ids, []
)

for user in users:
    print(user['id'], user['name'])

 

 

I should be missing something very trivial or connectiong to Odoo online requires something else?

Thanks for your support on my first steps into Odoo API land,

Fausto

 

0
Avatar
Ignorer
Avatar
Anabela Damas
Meilleure réponse

Hi, 

A python to create users in my Openerp : 

# encoding: utf-8

from base64 import b64decode
import time
import xml.etree.ElementTree as ET
import datetime
from random import randint
from pprint import pprint
from xml.dom.minidom import parse, parseString
import xmlrpclib
import sys


class OpenERPClient:
    def __init__(self, host, port, username, password, dbname):
        self._host = host
        self._port = port
        self._username = username
        self._password = password
        self._dbname = dbname
        self._uid = None
        self._sock = None

    def login(self):
        sock_common = xmlrpclib.ServerProxy(
            "http://%s:%s/xmlrpc/common" % (self._host, self._port)
        )

        self._uid = sock_common.login(
            self._dbname, 
            self._username, 
            self._password)

        self._sock = xmlrpclib.ServerProxy(
            "http://%s:%s/xmlrpc/object" % (self._host, self._port)
        )

    def _exec_module_method(self, module, method, *args):
        return self._sock.execute(
            self._dbname, self._uid, self._password, 
            module, method, *args)


class TestClient(OpenERPClient):
    
    def create_user(self, data_dict):
        return self._exec_module_method(
            'res.users', 
            'create', 
            data_dict)

 

if __name__ == "__main__":

#(host, port, username, password, dbname)
    testobj = TestClient("192.168.250.110", "8069", "admin", "123qwe", "database")
    testobj.login()
    testobj.create_user({'name':'John','active': True,
                            'login': 'john',
                            'password': 'qwerty',
                            'tz': 'Europe/Lisbon', })

0
Avatar
Ignorer
Fausto R.
Auteur

thanks, when using your sample, what are the host and port I should use for Odoo online?

Anabela Damas

Sorry, I don't know this script is local...

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Has anyone integrated Helpdesk with Zoom for meeting scheduling?
api
Avatar
Avatar
1
août 25
1290
Using API check if Odoo is using Odoo sh or on-premises hosting. Résolu
api
Avatar
Avatar
1
août 25
1674
External API XMLRPC Authentication Keeps Replying with false
api
Avatar
Avatar
Avatar
2
juil. 25
4568
API xmlrpc - upload pdf bills to account Résolu
api
Avatar
Avatar
Avatar
3
juil. 25
1743
Odoo API connection credential - How to get these credentials?
api
Avatar
Avatar
1
juin 25
3573
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now