Skip to Content
Odoo Menu
  • Prisijungti
  • Išbandykite nemokamai
  • Programėlės
    Finansai
    • Apskaita
    • Pateikimas apmokėjimui
    • Sąnaudos
    • Skaičiuoklė (BI)
    • Dokumentai
    • Pasirašymas
    Pardavimai
    • CRM
    • Pardavimai
    • Kasų sistema - Parduotuvė
    • Kasų sistema - Restoranas
    • Prenumeratos
    • Nuoma
    Svetainės
    • Svetainių kūrėjimo įrankis
    • El. Prekyba
    • Internetinis Tinklaraštis
    • Forumas
    • Tiesioginis pokalbis
    • eMokymasis
    Tiekimo grandinė
    • Atsarga
    • Gamyba
    • PLM
    • Įsigijimai
    • Priežiūra
    • Kokybė
    Žmogaus ištekliai
    • Darbuotojai
    • Įdarbinimas
    • Atostogos
    • Įvertinimai
    • Rekomendacijos
    • Transporto priemonės
    Rinkodara
    • Socialinė rinkodara
    • Rinkodara el. paštu
    • SMS rinkodara
    • Renginiai
    • Rinkodaros automatizavimas
    • Apklausos
    Paslaugos
    • Projektas
    • Darbo laiko žiniaraščiai
    • Priežiūros tarnyba
    • Pagalbos tarnyba
    • Planavimas
    • Rezervacijos
    Produktyvumas
    • Diskucija
    • Patvirtinimai
    • IoT
    • VoIP
    • Žinių biblioteka
    • WhatsApp
    Trečiųjų šalių programos Odoo Studija Odoo debesijos platforma
  • Pramonės šakos
    Mažmeninė prekyba
    • Knygynas
    • Drabužių parduotuvė
    • Baldų parduotuvė
    • Maisto prekių parduotuvė
    • Techninės įrangos parduotuvė
    • Žaislų parduotuvė
    Food & Hospitality
    • Barai ir pub'ai
    • Restoranas
    • Greitasis maistas
    • Guest House
    • Gėrimų platintojas
    • Hotel
    Nekilnojamasis turtas
    • Real Estate Agency
    • Architektūros įmonė
    • Konstrukcija
    • Estate Managament
    • Sodininkauti
    • Turto savininkų asociacija
    Konsultavimas
    • Accounting Firm
    • Odoo Partneris
    • Marketing Agency
    • Teisinė firma
    • Talentų paieška
    • Auditai & sertifikavimas
    Gamyba
    • Textile
    • Metal
    • Furnitures
    • Maistas
    • Brewery
    • Įmonių dovanos
    Sveikata & Fitnesas
    • Sporto klubas
    • Akinių parduotuvė
    • Fitneso Centras
    • Sveikatos praktikai
    • Vaistinė
    • Kirpėjas
    Trades
    • Handyman
    • IT įranga ir palaikymas
    • Saulės energijos sistemos
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Kiti
    • Nonprofit Organization
    • Aplinkos agentūra
    • Reklaminių stendų nuoma
    • Fotografavimas
    • Dviračių nuoma
    • Programinės įrangos perpardavėjas
    Browse all Industries
  • Bendrija
    Mokykitės
    • Mokomosios medžiagos
    • Dokumentacija
    • Sertifikatai
    • Mokymai
    • Internetinis Tinklaraštis
    • Tinklalaidės
    Skatinkite švietinimą
    • Švietimo programa
    • Scale Up! Verslo žaidimas
    • Aplankykite Odoo
    Gaukite programinę įrangą
    • Atsisiųsti
    • Palyginkite versijas
    • Leidimai
    Bendradarbiauti
    • Github
    • Forumas
    • Renginiai
    • Vertimai
    • Tapkite partneriu
    • Services for Partners
    • Registruokite jūsų apskaitos įmonę
    Gaukite paslaugas
    • Susiraskite partnerį
    • Susirask buhalterį
    • Susitikti su konsultantu
    • Diegimo paslaugos
    • Klientų rekomendavimas
    • Palaikymas
    • Atnaujinimai
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Gaukite demo
  • Kainodara
  • Pagalba

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

  • CRM
  • e-Commerce
  • Apskaita
  • Atsarga
  • PoS
  • Projektas
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Žymos (View all)
odoo accounting v14 pos v15
About this forum
Pagalba

ProtocolError for localhost:8069/xmlrpc/2/common: 409

Prenumeruoti

Get notified when there's activity on this post

This question has been flagged
pythonapixmlrpcodoov15
2 Replies
4939 Rodiniai
Portretas
Ali Ammar

I write an API to create user in odoo database

if I enter username and password for existing user at first time I receive the message that i add in this case in second time i receive conflict message and status code and the server stop receive any thing what ever I request I receive conflict and the problem need restart the server 

any solution ??

my code:

 @http.route('/register',  auth="public",csrf=False, website=True, methods=['POST'],type="json")

    defregister(self,idd= None, **kw):

        un='perla'

        password1 = 'perla'

        db = 'perla'

        body = request.jsonrequest

        username = body['body']['username']

        password = body['body']['password']


        common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(self.url))

        print(common)

        g = True

        try:

            print('uid')
            uid = common.authenticate(db,un, password1, {})

            print(uid)

            print('uid')

        except:

            response = json.dumps({ 'jsonrpc': '2.0', 'message': 'Unauthorized!'})

            return Response(            response, status=401,            headers=[('Content-Type', 'application/json'), ('Content-Length', 100)]                )

           
        if(g== False):

            print("false")

            print(Response)

                     print('false 222 ')


            # return Response

            response = json.dumps({ 'jsonrpc': '2.0', 'message': 'Unauthordecfedceized!'})

            returnResponse(            response, status=401,            headers=[('Content-Type', 'application/json'), ('Content-Length', 100)]

                )

                    else:

            print("else")
            models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(self.url))

            print("EMP")

        try:

            print('try')

            is_there= models.execute_kw(self.db, uid, self.password, 'res.users', 'search_count', [[['login', '=', username]]])

            ifis_there :

                response=json.dumps({ 'jsonrpc': '2.0', 'message': 'This User is already exist'})

                Response.status = '409'

                returnresponse

            else :

                user_id = models.execute_kw(self.db, uid, password1, 'res.users', 'create', [{'name': username, 'password' : password, 'login' :username ,'sel_groups_1_9_10':9, 'sel_groups_25_26_27' : 26,'is_active' :False}])

            print('user_id' + str(user_id))


        exceptExceptionase :

                        response=json.dumps({ 'jsonrpc': '2.0', 'message': 'This User is already exist'})            Response.status = '409'

            return Response( response, status=409,            headers=[('Content-Type', 'application/json'), ('Content-Length', 100)]                )

        ifuser_id :

            date_now = str(datetime.today())

            print('date_now  >>>'  +str(date_now))


            payload = {                'id': user_id,

                'username': username, 

               'password': password,

                'login' :username ,

                'is_active':False,

                'timestamp' : date_now,}

            # user_details = '{"id" :"%s" , "username" : "%s" , "timestamp":"%s"}'  %(user_id ,username,date_now)

            SECRET='ali.ammar'

            enc = jwt.encode(payload, SECRET)

              new_user_id_count =models.execute_kw(self.db, uid, password1, 'user.token', 'search_count', [[['name' , '=', user_id]]])

              create_user_verification = models.execute_kw(self.db, uid, password1, 'user.verification', 'create', [{'name': user_id,'is_valid' : True}])

            print("create_user_verification" + str(create_user_verification))

            ifnew_user_id_count:

                models.execute_kw(self.db, uid, password1, 'user.token', 'write', [['name' , '=' , user_id], {'token': enc}])

            else :

                models.execute_kw(self.db, uid, password1, 'user.token', 'create', [{'name': user_id, 'token': enc }])

            uid=0

            return json.dumps({"details":payload})

                    else:

            return json.dumps({'Error': "Invalid credentials"})  

0
Portretas
Atmesti
Portretas
Ali Ammar
Autorius Best Answer

the error come from werkzeug.wrappers  when I set :

Response.status = '409' 

all Response will blocked 

the solution is in use :

 response = json.dumps({ 'jsonrpc': '2.0', 'message': 'This User is already exist!'})

 return Response(            response, status=409,headers=[('Content-Type', 'application/json'), ('Content-Length', 100)]        )  

0
Portretas
Atmesti
Portretas
Ahmed
Best Answer

hey...
first of all, you DON'T have to use XMLRPC to create new records in the odoo (the controller LIVE in side odoo) 
your can just use some thing like this:

@http.route('/create', auth='public')
    def index(self, **kw):
    s = http.request.env['hr.res'].sudo()
    vals ={
            'name':'bo mohamad',
            'password':'cola_bandora',
           }
    s.create(vals)
second of all, the table 'res.usres' is very sensitive to odoo, you can't create users programmatically.
odoo will redirect you with warning that you can only create users from configuration pannel (which is the res.users table)

0
Portretas
Atmesti
Ali Ammar
Autorius

the error is not come from create
it com from here uid = common.authenticate(db,un, password1, {})
after tow request it fail the server and go in conflict status

Ahmed

for that specific problem i can tell you this:
1- common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(self.url))
it's preferred to hold the URL of your database in a variable, because "self.url" can change from page to page. try 'localhost:8069' instead.
2- double check the authentication credentials (db , username and password)
3- remove try-catch statement or print the error to have more visual on the error messages
4- avoid using json.dumps and mush as possible. odoo will use this function any way ander the hood for you.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registracija
Related Posts Replies Rodiniai Veikla
Error with call to external API
python api odoo
Portretas
Portretas
1
rugp. 25
2458
what is the different between @api.model adn @api.model_create_multi in odoo 15? Solved
api odoo v15
Portretas
Portretas
1
spal. 22
7431
I need to update new field which i have added by the inheritance automatically in odoo15 Solved
python odoo v15
Portretas
Portretas
2
liep. 22
2867
API attachment question
python api xmlrpc
Portretas
Portretas
Portretas
Portretas
3
birž. 22
7625
haw create action with xmlrpc odoo 14?
python xmlrpc odoo
Portretas
Portretas
1
geg. 22
4176
Bendrija
  • Mokomosios medžiagos
  • Dokumentacija
  • Forumas
Atvirasis kodas
  • Atsisiųsti
  • Github
  • Runbot
  • Vertimai
Paslaugos
  • Odoo.sh talpinimas
  • Palaikymas
  • Atnaujinti
  • Pritaikytas programavimo kūrimas
  • Švietimas
  • Susirask buhalterį
  • Susiraskite partnerį
  • Tapkite partneriu
Apie mus
  • Mūsų įmonė
  • Prekės ženklo turtas
  • Susisiekite su mumis
  • Darbo pasiūlymai
  • Renginiai
  • Tinklalaidės
  • Internetinis Tinklaraštis
  • Klientai
  • Teisinis • Privatumas
  • Saugumas
الْعَرَبيّة 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 yra atvirojo kodo verslo programų rinkinys, kuris apima visas įmonės poreikius: CRM, El. Prekybą, Apskaitą, Atsargų, Kasų sistemą, Projektų valdymą ir kt.

Unikali Odoo vertės pasiūla – būti tuo pačiu metu labai lengvai naudojama ir visiškai integruota sistema.

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