Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ declare class Odoo {
* @param {String} model Model name in Odoo.
* @param {String} method Name of method in Odoo.
* @param {Array<Object>} params Params in to execute from Odoo.
* @param {Object} [context] Context parameterto execute from Odoo.
*/
execute_kw: (model: string, method: string, params: Array<Object>) => Promise<any>;
execute_kw: (model: string, method: string, params: Array<Object>, context?: Object | undefined) => Promise<any>;
/**
* call workflow in odoo.
*
Expand Down
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ var Odoo = /** @class */ (function () {
* @param {String} model Model name in Odoo.
* @param {String} method Name of method in Odoo.
* @param {Array<Object>} params Params in to execute from Odoo.
* @param {Object} [context] Context parameterto execute from Odoo.
*/
this.execute_kw = function (model, method, params) { return __awaiter(_this, void 0, void 0, function () {
this.execute_kw = function (model, method, params, context) { return __awaiter(_this, void 0, void 0, function () {
var clientOptions, client, fparams;
return __generator(this, function (_a) {
clientOptions = {
Expand All @@ -118,8 +119,11 @@ var Odoo = /** @class */ (function () {
this.password,
model,
method,
params
params,
];
if (context !== undefined) {
fparams.push(context);
}
return [2 /*return*/, new Promise(function (resolve, reject) {
client.methodCall('execute_kw', fparams, function (error, value) {
error ? reject(error) : resolve(value);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "async-odoo-xmlrpc",
"version": "2.0.0",
"version": "2.1.0",
"description": "Nodejs client to call Odoo RPC's through xmlrpc library.",
"author": {
"name": "NguyenVanTien2009",
Expand Down
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class Odoo {
* @param {String} model Model name in Odoo.
* @param {String} method Name of method in Odoo.
* @param {Array<Object>} params Params in to execute from Odoo.
* @param {Object} [context] Context parameterto execute from Odoo.
*/
this.execute_kw = async (model, method, params) => {
this.execute_kw = async (model, method, params, context) => {
var clientOptions = {
host: this.host,
port: this.port,
Expand All @@ -85,9 +86,13 @@ class Odoo {
this.password,
model,
method,
params
params,
];

if (context !== undefined) {
fparams.push(context)
}

return new Promise((resolve, reject) => {
client.methodCall('execute_kw', fparams, (error, value) => {
error ? reject(error) : resolve(value);
Expand Down