Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
5900 Weergaven

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

Avatar
Annuleer
Beste antwoord

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


Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
jul. 25
1405
2
nov. 24
6167
2
okt. 24
3132
2
aug. 24
1824
3
jul. 24
8218