Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
8072 Widoki

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


i am using postgre and odoo10

Awatar
Odrzuć
Najlepsza odpowiedź

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>)



Awatar
Odrzuć
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!

Powiązane posty Odpowiedzi Widoki Czynność
2
cze 24
1476
1
gru 23
1192
1
kwi 23
1388
1
mar 23
2231
0
gru 22
1814