Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4405 Vizualizări

Hi all,

I have my own module which calls an API to get some data.

I just want pass this API data, located in my own module, to the invoice line to create a new invoice.

Thanks to all in advance! =)

Imagine profil
Abandonează
Cel mai bun răspuns

Hello my friend;

For this you need to work with XML_RPC or Curl.

Here are some examples and links to know how to work with:

XML_RPC:

Links:

https://doc.odoo.com/6.0/developer/6_22_XML-RPC_web_services/

http://thierry-godin.developpez.com/openerp/openerp-xmlrpc-php-fr/

http://thierry-godin.developpez.com/openerp/openerp-xmlrpc-php-en/

CURL:

Link:

https://www.odoo.com/fr_FR/forum/help-1/question/use-xmlrpc-webservice-through-cloud-version-of-odoo-55377

Example:

import pycurl, json

from StringIO import StringIO 

github_url = 'Your_api_link

buffer = StringIO()

c = pycurl.Curl()

c.setopt(pycurl.URL, github_url)

c.setopt(pycurl.HTTPHEADER, ['X-Postmark-Server-Token: API_TOKEN_HERE','Accept: application/json'])

c.setopt(c.WRITEFUNCTION, buffer.write)

c.perform()

c.close()

body = buffer.getvalue()

#print(body)

resp = json.loads(body)

if resp['result'] != 'ok' :

print 'Error : (' + resp['error_code'] +')' + resp['error']

else :

#print resp['list']

for gr in resp['list'] :

print gr['name']

Good LUCK & Regards.


Imagine profil
Abandonează

please vote :)

Related Posts Răspunsuri Vizualizări Activitate
1
mar. 23
2086
0
apr. 22
1317
1
mai 15
8772
2
sept. 20
9011
4
iun. 20
3721