Odoo Help


How to add a javascript handler for button click event in openerp 7?

on 4/10/15, 4:23 AM 8,998 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--
| 7 8 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 and 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--

| 6 8 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">

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

3 follower(s)


Asked: 4/10/15, 4:23 AM
Seen: 8998 times
Last updated: 12/22/16, 2:21 PM