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 add a javascript handler for button click event in openerp 7?

on 4/10/15, 4:23 AM 3,736 views

Hello, I want to make a handler for button in footer area using javascript. My view model looks below :

<record id="view_rnd_history_form" model="ir.ui.view">
<field name="name">rnd.history.form</field>
<field name="model">rnd.batch.record.history</field>
<field name="arch" type="xml">
<form string="History" version="7.0">
<field name="br_id" colspan="2"/>
<label for="start_date" string="Date"/>
<field name="start_date" class="oe_inline"/> -
<field name="end_date" class="oe_inline"/>
<field name="batch_number" colspan="2"/>
<field name="parameter_id" colspan="2"/>
<button name="show_history" string="_Show" class="oe_highlight" onclick="alert('hello');"/>

I'm confuse. the onclick attribute seem removed by qweb render process. I want a simple thing, user click on show_history button, then it call a simple javascript function or action client. Any information will be appreciate. Thank you.


Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/17/15, 12:16 PM

I have created a module specifically to do this, you can found it in Odoo apps like "Soltein Button Widget"

The use of this module is like the following example:

<solt_button string="_Show">
       jQuery('footer button:first').click(function() { alert('hello'); });

In the code of the button you could access to the widget instance using self and also to the fields of the form using self.view.fields

On 4/13/15, 12:08 AM

I added javascript code like this :

<button name="show_history" string="_Show" class="oe_highlight"/>
jQuery('footer button:first').click(function() { alert('hello'); });

 The alert message never called after click the button. Well, I think it related on rendering process by qweb. The jQuery event handler is never attach to button node.  Is it possible to listen render event in qweb? Thanks.


Francesco OpenCode

--Francesco OpenCode--
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/10/15, 9:00 AM
<form string="BlaBla">

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

3 follower(s)


Asked: 4/10/15, 4:23 AM
Seen: 3736 times
Last updated: 7/17/15, 12:16 PM