Skip to content

Commit c52eace

Browse files
committed
[ADD] getContext and updateContext to backend
1 parent f8143ec commit c52eace

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

odoorpc.service.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,15 @@ var OdooRPCService = (function () {
193193
return this.sendRequest("/web/dataset/search_read", params);
194194
};
195195
OdooRPCService.prototype.updateContext = function (context) {
196-
this.context = context;
196+
var _this = this;
197197
localStorage.setItem("user_context", JSON.stringify(context));
198+
var args = [[this.context.uid], context];
199+
this.call("res.users", "write", args, {})
200+
.then(function () { return _this.context = context; })
201+
.catch(function (err) { return _this.context = context; });
202+
};
203+
OdooRPCService.prototype.getContext = function () {
204+
return this.context;
198205
};
199206
OdooRPCService.prototype.call = function (model, method, args, kwargs) {
200207
kwargs = kwargs || {};

odoorpc.service.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,15 @@ export class OdooRPCService {
202202
}
203203

204204
public updateContext(context: any) {
205-
this.context = context;
206205
localStorage.setItem("user_context", JSON.stringify(context));
206+
let args = [[(<any>this.context).uid], context];
207+
this.call("res.users", "write", args, {})
208+
.then(()=>this.context = context)
209+
.catch((err: any) => this.context = context);
210+
}
211+
212+
public getContext() {
213+
return this.context;
207214
}
208215

209216
public call(model: string, method: string, args: any, kwargs: any) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-odoo-jsonrpc",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Odoo JsonRPC Service for angular 2",
55
"main": "odoorpc.service.js",
66
"scripts": {

0 commit comments

Comments
 (0)