Odoo Help


This community 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.


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

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

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


Drees Far

--Drees Far--
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
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 :)

Drees Far
on 7/27/15, 8:24 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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