Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8089 Lượt xem

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


i am using postgre and odoo10

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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



Ảnh đại diện
Huỷ bỏ
Tác giả

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 !

Tác giả

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

Tác giả

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

Tác giả

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!

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 24
1495
1
thg 12 23
1235
1
thg 4 23
1410
1
thg 3 23
2250
0
thg 12 22
1827