Skip to content

Commit 295f59c

Browse files
committed
Send context through kwargs
1 parent 24134be commit 295f59c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

lib/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Odoo.prototype.connect = function (cb) {
5454
self.uid = response.result.uid;
5555
self.sid = res.headers['set-cookie'][0].split(';')[0];
5656
self.session_id = response.result.session_id;
57+
self.context = response.result.user_context;
5758

5859
return cb(null, response.result);
5960
});
@@ -65,7 +66,9 @@ Odoo.prototype.connect = function (cb) {
6566
// Create record
6667
Odoo.prototype.create = function (model, params, callback) {
6768
this._request('/web/dataset/call_kw', {
68-
kwargs: {},
69+
kwargs: {
70+
context: this.context
71+
},
6972
model: model,
7073
method: 'create',
7174
args: [params]
@@ -85,7 +88,9 @@ Odoo.prototype.get = function (model, id, callback) {
8588
Odoo.prototype.update = function (model, id, params, callback) {
8689
if (id) {
8790
this._request('/web/dataset/call_kw', {
88-
kwargs: {},
91+
kwargs: {
92+
context: this.context
93+
},
8994
model: model,
9095
method: 'write',
9196
args: [[id], params]
@@ -96,7 +101,9 @@ Odoo.prototype.update = function (model, id, params, callback) {
96101
// Delete record
97102
Odoo.prototype.delete = function (model, id, callback) {
98103
this._request('/web/dataset/call_kw', {
99-
kwargs: {},
104+
kwargs: {
105+
context: this.context
106+
},
100107
model: model,
101108
method: 'unlink',
102109
args: [[id]]
@@ -106,7 +113,9 @@ Odoo.prototype.delete = function (model, id, callback) {
106113
// Search records
107114
Odoo.prototype.search = function (model, params, callback) {
108115
this._request('/web/dataset/call_kw', {
109-
kwargs: {},
116+
kwargs: {
117+
context: this.context
118+
},
110119
model: model,
111120
method: 'search',
112121
args: [params]

test/test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var assert = require('assert'),
55
var config = {
66
host: 'odoo4yopping.vagrantshare.com',
77
port: 80,
8-
database: 'pruebas',
8+
database: '4yopping',
99
username: 'admin',
1010
password: '4yopping'
1111
};
@@ -79,9 +79,10 @@ describe('Odoo', function () {
7979
setTimeout(function () {
8080
assert(callback.calledWith(null));
8181
assert.equal(typeof callback.args[0][1], 'object');
82-
assert.notEqual(odoo.uid, undefined);
83-
assert.notEqual(odoo.sid, undefined);
84-
assert.notEqual(odoo.session_id, undefined);
82+
assert(odoo.uid);
83+
assert(odoo.sid);
84+
assert(odoo.session_id);
85+
assert(odoo.context);
8586

8687
done();
8788
}, 2000);

0 commit comments

Comments
 (0)