跳至内容
菜单
此问题已终结
1 回复
5911 查看

Hi,

I'm trying to get the company_id of the company the logged in user belongs to.


get_company_id: function(context) {

  var self = this;

  var ret = 0;

    new Model('res.users') .query(['id', 'company_id'])

   .filter([["id", "=", context.dataset.context.uid]])

   .first()

   .done(function (records) {

     console.log(records.company[0]);

     self.ret = records.company_id[0];

   });

  return ret;

},


inside the done function the value is correct.

outside the value is always 0.

is it possible to get a value out of the done function, or is there something missing?

thanks for your help

Klaus

形象
丢弃
最佳答案

Call python function using javascript

https://www.odoo.com/documentation/9.0/howtos/web.html#contacting-models

Then return company

self.env['res.users'].search([('id', '=', self._uid)]).company_id


形象
丢弃
相关帖文 回复 查看 活动
0
7月 25
1419
2
11月 24
6211
2
10月 24
3158
2
8月 24
1833
3
7月 24
8229