Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5894 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 25
1404
2
thg 11 24
6159
2
thg 10 24
3128
2
thg 8 24
1824
3
thg 7 24
8215