2011-08-18 20:39:20 +00:00
<!DOCTYPE html>
< html style = "height: 100%" >
< head >
< meta http-equiv = "content-type" content = "text/html; charset=utf-8" / >
2011-08-18 23:38:11 +00:00
< title > OpenERP web_rpc example< / title >
2011-08-18 21:26:35 +00:00
< style type = "text/css" >
pre.run {
border: 1px solid black; margin:0;padding:4px;
}
< / style >
< script type = "text/javascript" src = "/base/webclient/js?mods=web_rpc" > < / script >
2011-08-18 20:39:20 +00:00
< script type = "text/javascript" >
$(function() {
2011-08-18 20:58:20 +00:00
$("#ex1but").bind("click",function(){
2011-08-18 23:38:11 +00:00
eval($("#ex1").text());
2011-08-18 20:58:20 +00:00
});
2011-08-18 20:39:20 +00:00
});
< / script >
< / head >
< body >
2011-08-18 23:38:11 +00:00
< h1 > OpenERP web_rpc examples< / h1 >
< h2 > Example 1: Display a list of defined ir.model < button id = "ex1but" > Run it !< / button > < / h2 >
2011-08-18 20:39:20 +00:00
< h3 > Code: < / h3 >
2011-08-18 21:26:35 +00:00
< pre >
< script type="text/javascript" src="/base/webclient/js?mods=web_rpc"> < /script>
< script type="text/javascript">
< pre id = "ex1" class = "run" >
2011-08-18 23:38:11 +00:00
var c = openerp.init(); // get a new webclient
c._modules_loaded = true; // Hack to prevent loading of additional modules
var s = new c.base.Session(); // setup a Session
2011-12-13 16:15:54 +00:00
s.login("web-trunk", "admin", "admin", function() {
2011-08-18 23:38:11 +00:00
var ds = new c.base.DataSetSearch(s, "ir.model"); // DataSetSearch used to search, read
ds.read_slice(['name','model'], {}, function(users){
for(var i in users) {
$("#ex1res").append("< li> " + users[i].model + " (" + users[i].name + ") < /li> ")
}
});
}
);
2011-08-18 21:26:35 +00:00
< / pre > < /script>
2011-08-18 20:39:20 +00:00
< / pre >
2011-08-18 23:38:11 +00:00
< h3 > Div for output:< / h3 >
2011-08-18 20:39:20 +00:00
< div id = "ex1res" style = "border: 1px solid black;" >
< / div >
2011-08-18 23:38:11 +00:00
< h2 > Help me to complete this example page on < a href = "http://bazaar.launchpad.net/~openerp/openerp-web/trunk/view/head:/addons/web_rpc/static/src/example.html" > launchpad< / a > < / h2 >
2011-08-18 20:39:20 +00:00
< / body >
< / html >