Last active
November 8, 2019 16:28
-
-
Save hostelix/a2a61542a6d3a91cce75bb8a10f2c10d to your computer and use it in GitHub Desktop.
OdooRpc make requests to the server odoo by means of rpc (axios)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| class OdooRpc { | |
| constructor() { | |
| this._actions = { | |
| dataset_call: 'web/dataset/call', | |
| dataset_call_kw: 'web/dataset/call_kw', | |
| dataset_search_read: 'web/dataset/search_read', | |
| search_read: 'search_read', | |
| }; | |
| this._defaults = { | |
| jsonrpc: '2.0', | |
| method: 'call' | |
| }; | |
| } | |
| __rpc(url, params) { | |
| return axios.post(url, { | |
| ...this._defaults, | |
| params: params | |
| }); | |
| } | |
| __call(params) { | |
| return this.__rpc(this._actions.dataset_call, params); | |
| } | |
| __call_kw(params) { | |
| return this.__rpc(this._actions.dataset_call_kw, params); | |
| } | |
| __search_read(params) { | |
| return this.__rpc(this._actions.dataset_search_read, params); | |
| } | |
| create(params) { | |
| const {model, args} = params; | |
| return this.__call({model, args, method: 'create'}); | |
| } | |
| write(params) { | |
| const {model, args} = params; | |
| return this.__call({model, args, method: 'write'}); | |
| } | |
| unlink(params) { | |
| const {model, args} = params; | |
| return this.__call({model, args, method: 'unlink'}); | |
| } | |
| search_read(params) { | |
| const {model, args} = params; | |
| return this.__call({model, args, method: 'search_read'}); | |
| } | |
| search(params) { | |
| const {domain, fields, limit = 80, model, offset = 0, sort = ""} = params; | |
| return this.__search_read({model, fields, domain, sort, limit, offset}); | |
| } | |
| } | |
| export default OdooRpc; |
Author
args es un array de parametros que se envian al metodo en erp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para usar en los args que información se envia?