Overview of js code to access OpenERP with JSON-RPC
We use the git capabilities to illustrate 3 implementation of a client js request to OpenERP using JSON.
All these implementation will:
- Login to openerp using JSON-RPC - store a session id. - change HTML to write "Login successfull" along with the session id received.
- Query OpenERP upon 'res.partner' for fields 'name' and 'city' - change HTML to write the result in a HTML list.
The first branch called
fromscratch tries not to include any
with JQuery only.
The second branch
picked-oe-lib tries to make a smart pick of openerp
The third branch
The default branch
master follows the
fromscratch solution. Feel free
to ask difference between branches so as to get informative differential.
This means that for each download of json or URL, a first exchange with the server will asks for some policies. And client HttpRequest will accept or not the script based on these permissions.
You can force your openerp server to set these headers thanks to apache when used in proxy mode by adding these in your apache configuration:
Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "POST, GET, OPTIONS" Header set Access-Control-Allow-Headers "origin, content-type, accept"