Odoo Help


How to create a button in JS and how its call to openerp method?

on 7/8/15, 1:35 AM 1,314 views

I need to create a button in js file and i want access openerp method by using this button...


Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 7/27/15, 8:19 AM

To create a button in js you should create a qweb module.

Here i give you an example.

you create a directory called static in which you put a directory named src in which you put three directory called js, xml, css  with .css , .js and .wml extansion of files.

Call the module web_example.

So in your:


openerp.web_example = function (instance) {

instance.web.client_actions.add('example.action', 'instance.web_example.Action');

instance.web_example.Action = instance.web.Widget.extend({

template: 'web_example.action',

events: {

'click .oe_web_example_file button': 'Upload',



instance.web.form.custom_widgets.add('momo2', 'instance.web_example.Action');




<div t-name="web_example.action" class="oe_web_example oe_web_example_stopped">

<p class="oe_web_example_file">

<input type="file" id="fileUpload" name="file" />

<button>entire file</button>





.openerp .oe_web_example {

color: black;

background-color: white;

height: 100%;


In your __openerp__.py:

'js': ['static/src/js/xxxx.js'],

'css': ['static/src/css/xxxx.css'],

'qweb': ['static/src/xml/xxxx.xml'],

Here is also a useful link:


Here is an other link https://www.odoo.com/documentation/8.0/howtos/web.html Vote please :)

Vale Trood
on 7/27/15, 8:24 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/8/15, 1:35 AM
Seen: 1314 times
Last updated: 8/3/15, 8:26 AM