Hello,
I use tryton in the company and I want to give some customers the possibility to insert some movements.
The Tryton web client is a troopo articulated for the people who will have to make the insertions.
For this reason I would like to implement a project in Laravel (PHP), which interfaces to the tryton database through RPC, which has a very friendly interface.
I can not find documentation on how to use RPC.
The operations I should perform are:
User Login and User Logout
Various Queries (products, parties and moves)
Insert in Tryton of Internal Shipment and Return Customer Shimpment.
We have build a webapp based on EmberJS (Javascript) to lend products to users. The app is directly talking to Tryton (like sao, the webapp). We have also some Python scripts which can directly talk to Tryton.
The main thing is that you have to do JSON-RPC calls via HTTP. When you want to login send a request something like {âmethodâ: âcommon.db.loginâ, âparamsâ: [âadminâ, {âpasswordâ : âyour passwordâ}] } . Tryton will return some data like session id which you should use in the http-header for the next calls (run Tryton server in debug mode in the foreground so you can see messages). Then call to get the user preferences (also needed). After that you can do anything in the database as long as you stay with the right syntax.
Iâm running tests on a local server. I am sending JSON requests like:
{ âmethodâ:âcommon.server.versionâ, âparamsâ:[null, null], âidâ: 1 }
The trytond server responds with the message: HTTP 1.1 - 500.
Why do I always receive âInternal Server Errorâ?
Can someone post me a correct syntax of sending JSON-RPC request?
Can this request be sent in Jscript (Jquery)?
If you are working in the browser, be sure to run also your javascript from exactly the same address:port as you run Tryton from. Hence you need Tryton to serve your index.html and javascript files. You will run in trouble with CORS (cross site scripting) which is hard disabled in the newest browsers. See also your development console in the browser, vital information is showed there. Iâm also using console.log() a lot.
An extreem basic simple Python 2 script which will work with Tryton 4.6:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from jsonrpclib import Server as ServerProxy
server = ServerProxy('http://<ip-address>:<port>', verbose=1)
result = server.common.server.version([])
print result
You will get an error that the response is not a Dict, but you can see that it comes back with the server version.
Iâm using MAC OSX 10.14 with Python 2.7.1
Tryton 4.6 in viertualenv environment
Terminal: (env)> trytond -c trytond.conf -v
File test.html launched on safari and chrome browser
The example does not request to make an OPTIONS call. I guess if it does it is to retrieve CORS because of cross-domain. This means that you are not running the command from a page from the same domain.
You will need to support CORS (Tryton does not have such option in base, it should be managed by an external tool) or use a reverse proxy that dispatch to the right server.
I was able to execute the request correctly: laravel uses a different virtual server than the Tryton server. I created a page in html and called by Trytonâs localhost. Now works!
I tried to use the common.db.login call: from the server log I read that the login was executed, but how do I recover user and session? I tried querying an array created for this purpose with array [0] and array [1], but I get nothing. I tried to get the user ID with array [âidâ], but the session can not get it. can you give me a hand?
If I want to insert an internal shipment how should I dial the call? and to have all the customer shipment?
Hello to all,
I managed to get call id, user id and session.
Iâm learning Trytonâs json-rpc calls and I still have some gaps âŠ
After logging in (using the common.db.login method), is there a special procedure to save session data?
Iâve noticed that every time you run common.db.login the session changes.
I read that you need to insert user id and session at the first and second place in params.
However, I do not know the correct syntax for adding a new internal shipment and to be able to view the customer shipment list of a specific party ordered by actual date.
I need an example: I do not know how to dial the json call to add / edit.
What should I write in the âmethodâ field?
What should I write in the âparamsâ field?
Unfortunately, on the net there are no examples of real use of Trytonâs json-rpc