main question today is "is it possible to connect openerp from python jsonrpc ?"
sure, actually openerp-client use it, when you look on to its data to transfer, you will learn about how they communicate, here's the data when we login :
{"jsonrpc":"2.0","method":"call","params":{"db":"latestonair","login":"your_username","password":"your_password","base_location":"http://erp.nubeesystem.com","session_id":"a27057d83d344668b908b4d9520aa666","context":{"lang":"en_US","tz":false,"uid":4}},"id":"r23"}=
so: how ?
import json
import urllib2
import random
data = {
"jsonrpc": "2.0",
"method": "login",
"params": {"db":"latestonair","login":"username","password":"passowrd"},
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url='http://localhost:8069/jsonrpc', data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = json.load(result)
other data to analyze :
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e440999dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r120"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph"],"kwargs":{},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r119"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440399dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r118"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440259dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r616"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r622"}=
sure, actually openerp-client use it, when you look on to its data to transfer, you will learn about how they communicate, here's the data when we login :
{"jsonrpc":"2.0","method":"call","params":{"db":"latestonair","login":"your_username","password":"your_password","base_location":"http://erp.nubeesystem.com","session_id":"a27057d83d344668b908b4d9520aa666","context":{"lang":"en_US","tz":false,"uid":4}},"id":"r23"}=
so: how ?
import json
import urllib2
import random
data = {
"jsonrpc": "2.0",
"method": "login",
"params": {"db":"latestonair","login":"username","password":"passowrd"},
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url='http://localhost:8069/jsonrpc', data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = json.load(result)
other data to analyze :
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e440999dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r120"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph"],"kwargs":{},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r119"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440399dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r118"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440259dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r616"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r622"}=
..show all:.
.
main question today is "is it possible to connect openerp from python jsonrpc ?"
sure, actually openerp-client use it, when you look on to its data to transfer, you will learn about how they communicate, here's the data when we login :
{"jsonrpc":"2.0","method":"call","params":{"db":"latestonair","login":"your_username","password":"your_password","base_location":"http://erp.nubeesystem.com","session_id":"a27057d83d344668b908b4d9520aa666","context":{"lang":"en_US","tz":false,"uid":4}},"id":"r23"}=
so: how ?
import json
import urllib2
import random
data = {
"jsonrpc": "2.0",
"method": "login",
"params": {"db":"latestonair","login":"username","password":"passowrd"},
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url='http://localhost:8069/jsonrpc', data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = json.load(result)
other data to analyze :
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e440999dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r120"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph"],"kwargs":{},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r119"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440399dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r118"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440259dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r616"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r622"}=
sure, actually openerp-client use it, when you look on to its data to transfer, you will learn about how they communicate, here's the data when we login :
{"jsonrpc":"2.0","method":"call","params":{"db":"latestonair","login":"your_username","password":"your_password","base_location":"http://erp.nubeesystem.com","session_id":"a27057d83d344668b908b4d9520aa666","context":{"lang":"en_US","tz":false,"uid":4}},"id":"r23"}=
so: how ?
import json
import urllib2
import random
data = {
"jsonrpc": "2.0",
"method": "login",
"params": {"db":"latestonair","login":"username","password":"passowrd"},
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url='http://localhost:8069/jsonrpc', data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = json.load(result)
other data to analyze :
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e440999dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r120"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph"],"kwargs":{},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r119"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440399dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r118"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"fields_view_get","args":[false,"graph",{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1},true],"kwargs":{},"session_id":"151cc81b332e440259dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r616"}=
{"jsonrpc":"2.0","method":"call","params":{"model":"sale.order","method":"read_group","args":[[["state","not in",["draft","sent","cancel"]]],["amount_total","partner_id"],["partner_id"]],"kwargs":{"context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12,"show_address":1}},"session_id":"151cc81b332e240299dd7471196499c4","context":{"lang":"en_US","tz":"Asia/Jakarta","uid":12}},"id":"r622"}=
Hi.
ReplyDeleteThanks for the tip. When I run it, it shows:
urllib2.HTTPError: HTTP Error 404: NOT FOUND
My code is:
#!/usr/bin/env python
import json
import urllib2
import random
data = {
"jsonrpc": "2.0",
"method": "login",
"params": {"db":"test","login":"admin","password":"a"},
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url="http://127.0.0.1:8069/jsonrpc", data=json.dumps(data), headers={"Content-Type":"application/json",})
result = urllib2.urlopen(req)
result = json.load(result)
Know if the req variable is malformed?
Best Regards
CRAF
Hi. Thanks for the tips. When try code, show me:
ReplyDeleteurllib2.HTTPError: HTTP Error 404: NOT FOUND
any idea why?
Best Regards
CRAF