Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
8037 Vistas

how to get database values into java script   which is placed in xml 


i am using postgre and odoo10

Avatar
Descartar
Mejor respuesta

Hi Basha,

Please elaborate your question.

Or you could call python method in java script to call a python function. for example in java script new instance.web.Model(<model.name.in.quotes>).function_name(<yourfunction_name>)(<arguments>)



Avatar
Descartar
Autor

thank you can you please share any sample code

Hi

Suppose, you want to call has_group from res.users

var Users = new instance.web.Model('res.users');

Users.call('has_group', [<group_name>]).done(function res){ });

Thanks !

Autor

hi sushma

i didn't understood clearly

suppose i want phone_code from res.country

please specify the syntax for it

Hi,

Actually you can have country object in JS, directly you look for like country.phone_code.

Else

# JS

this.model_country = new Model("res.country");

self.model_country.call("get_phone_code", [obj,'IN']).then(function(result){

var phone_code = result['phone_code'] ; });

#python

@api.multi

def get_phone_code(self, Country_code):

res = {}

phone_code = # write code to find country from code

res['phone_code'] = phone_code

return res

Autor

please still i havent got solution for this

as per your above js code

i unable to get data

i tried by putting the phone_code in alert

This an example I've shared you, just refer and try as per you needs. Even though you will get lot of example withing odoo addons

Autor

Hi please any solution

<t t-foreach="values" t-as="value">

<input type="hidden" t-att-value="value.editor1" id="aaa"/>

<script type="text/javascript">

var a= document.getElementById("aaa").value;

alert(a);

document.getElementById("kkkr").innerHTML = a;

</script>

<span id="kkkr"> </span>

here iam getting only first record every time

How to get all records present in the table

Hi Basha,

You're fetching single values through document.getElement(), you need to call python method to JS, Please refer my above example for calling python into JS.

Thanks!

Publicaciones relacionadas Respuestas Vistas Actividad
2
jun 24
1342
1
dic 23
1150
1
abr 23
1291
1
mar 23
2106
0
dic 22
1754