[IMP] web_api improve example
bzr revid: al@openerp.com-20120830124337-4uraforhvgv18tff
This commit is contained in:
parent
19f2f72662
commit
01e5824fb0
|
@ -18,38 +18,34 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
$("body").on('click','button',function(ev){
|
$("body").on('click','button',function(ev){
|
||||||
eval($("pre.run").text());
|
console.log($("textarea").val());
|
||||||
|
eval($("textarea").val());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>OpenERP web_api examples</h1>
|
<h1>OpenERP web_api test</h1>
|
||||||
<h2>Example 1: Load the list of defined ir.model <button>Run it !</button></h2>
|
<h2>Example: Load the content of ir.model <button>Run it !</button></h2>
|
||||||
<blockquote>
|
|
||||||
<h3>Code: </h3>
|
|
||||||
<pre>
|
<pre>
|
||||||
<script type="text/javascript" src="/web/webclient/js"></script>
|
<script type="text/javascript" src="/web/webclient/js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<pre id="ex1" class="run">
|
<textarea rows="12" cols="100"id="ex1" class="run">
|
||||||
var instance = openerp.init(["web"]); // get a new instance
|
var instance = openerp.init(["web"]); // get a new instance
|
||||||
instance.session.session_bind(); // bind it to the right hostname
|
instance.session.session_bind(); // bind it to the right hostname
|
||||||
instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
|
instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
|
||||||
var ds = new instance.web.DataSetSearch(null, "ir.model");
|
var ds = new instance.web.DataSetSearch(null, "ir.model");
|
||||||
ds.read_slice(['name','model'], {}).then(function(models){
|
ds.read_slice(['name','model'], {}).then(function(models){
|
||||||
_.each(models,function(m,i){
|
_.each(models,function(m,i){
|
||||||
$("#ex1res").append("<li>" + m.model + " (" + m.name + ") </li>")
|
$("#result").append("<li>" + m.model + " (" + m.name + ") </li>")
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</pre></script>
|
});
|
||||||
|
</textarea>
|
||||||
|
</script></pre>
|
||||||
|
<h3>Result:</h3>
|
||||||
|
<pre id="result" class="result">
|
||||||
</pre>
|
</pre>
|
||||||
<h3>Div for output:</h3>
|
|
||||||
<div id="ex1res" class="result">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</blockquote>
|
|
||||||
<h2>Help me to complete this examples on <a href="http://bazaar.launchpad.net/~openerp/openerp-web/trunk/view/head:/addons/web_api/static/src/example.html">launchpad</a></h2>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue