Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
8090 Visninger

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


i am using postgre and odoo10

Avatar
Kassér
Bedste svar

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
Kassér
Forfatter

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 !

Forfatter

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

Forfatter

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

Forfatter

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!

Related Posts Besvarelser Visninger Aktivitet
2
jun. 24
1499
1
dec. 23
1236
1
apr. 23
1412
1
mar. 23
2251
0
dec. 22
1827