Odoo Ayuda

0

0
2 Answers
0
Avatar

Mohammed Amal

--Mohammed Amal--

2169
| 6 3 9
Malappuram, India
--Mohammed Amal--

Email : mohammedamal.n@gmail.com

Blog: https://www.blogger.com/profile/14877879550922602186

Mohammed Amal
26/5/17 2:46

use this to get a fields value from js

var Users = new openerp.Model('res.users');
Users.query(['name', 'login', 'user_email', 'signature']) .filter([['active', '=', true], ['company_id', '=', main_company]]) .limit(15) .all().then(function (users) { // do work with users records, you can access only fields said in query
     for(i in users){
         console.log(i.name)
     }
 });

please refer this link

However a call to py function or model is done only after all js functions are executed.
if you need to use this variable, you should call the js function inside .then(function (users){ and pass your values

for example

var self = this
var Users = new openerp.Model('res.users');
Users.query(['name', 'login', 'user_email', 'signature']) .filter([['active', '=', true], ['company_id', '=', main_company]]) .limit(15) .all().then(function (users) { // do work with users records, you can access only fields said in query
     for(i in users){
         console.log(i.name)
         self.your_function(sample_var)
     }
 });


0
Othmane Ghandi
26/5/17 11:14

Thank you Mohammed

I wrote this code. First the "ResCompany" variable took the name in "res.company" but when I refresh or change the name of my company, the variable "ResCompany" take the default value which is 'Ghandi'.

Is there any explanation ?

var CompanyName = 'Ghandi';
var
Model = require('web.Model');
var
ResCompany = new Model('res.company');
ResCompany
.query(['name'])
   .filter([['id', '=', 1]])
   .first()
   .then(function (company){
        CompanyName = company.name;
    });

Realizar una pregunta
Writer
Etiquetas
Keep Informed
1 seguidor(es)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now