Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

getting company_id in javascript

By
Klaus Staudt
on 9/23/16, 5:43 AM 176 views

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

0
shameem@aχoncoms
On 9/23/16, 7:49 AM

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


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/23/16, 5:43 AM
Seen: 176 times
Last updated: 9/23/16, 7:49 AM