Tags


1). Add js and xml file under resource folder.

rootfolder/static/src/css/petstore.css

rootfolder/static/src/js/petstore.js

aslo add these files on __openerp__.py file

11

2). petstore.js

openerp.petstore = function(instance, local) {

instance.web.form.widgets = instance.web.form.widgets.extend(
{
‘test’ : ‘instance.web.form.message’,
});

instance.web.form.message = instance.web.form.FieldChar.extend(
{
template: ‘test’,
start: function() {
var self=this;
$(‘button#message’).click(this.show_message);
},

show_message :function(){
alert($(‘span.oe_breadcrumb_item’).html());
}
});
}

 

3). rootfolder/static/src/xml/petstore.xml   (Qweb template file)

<?xml version=”1.0″ encoding=”utf-8″?>
<templates>
<t t-name=”test”>
<button name=”view_images” type=”object” id=”message” >Alert</button>
</t>
</templates>

 

4). call widget on data template

attach js and css on data file

<template id=”assets_backend” name=”petstore_assets” inherit_id=”web.assets_backend”>
<xpath expr=”.” position=”inside”>
<link rel=”stylesheet” href=”/petstore/static/src/css/petstore.css”/>
<script type=”text/javascript” src=”/petstore/static/src/js/petstore.js”/>
</xpath>
</template>

call widget

<field name=”name” widget=”test”/>

download source

Advertisements