Files
odoo_source/addons/web_rpc/static/src/example.html
T
Olivier Dony 9835cebe19 [MERGE] Use the new authenticate() API instead of login()
Using the new authenticate() API instead allows to pass
a user-agent environment along with the credentials.
The main use for the UA environment at this point is
to pass the base URL used to login, so that the server
may initialize its "web.base.url" global config parameters

bzr revid: odo@openerp.com-20111213161554-jbtrp94aatcnibne
2011-12-13 17:15:54 +01:00

52 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>OpenERP web_rpc example</title>
<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>
<script type="text/javascript">
$(function() {
$("#ex1but").bind("click",function(){
eval($("#ex1").text());
});
});
</script>
</head>
<body>
<h1>OpenERP web_rpc examples</h1>
<h2>Example 1: Display a list of defined ir.model <button id="ex1but">Run it !</button> </h2>
<h3>Code: </h3>
<pre>
&lt;script type="text/javascript" src="/base/webclient/js?mods=web_rpc"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
<pre id="ex1" class="run">
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
s.login("web-trunk", "admin", "admin", function() {
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("&lt;li&gt;" + users[i].model + " (" + users[i].name + ") &lt;/li&gt;")
}
});
}
);
</pre>&lt;/script&gt;
</pre>
<h3>Div for output:</h3>
<div id="ex1res" style="border: 1px solid black;">
&nbsp;
</div>
<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>
</body>
</html>