Odoo Help


How to call a javascript function from Odoo

Tarek Mohamed Ibrahim
on 6/15/15, 9:11 AM 3,221 views

I needed to write a method that exports some records programmatically, I checked and found the function that do the export is the javascript function : on_click_export_data found in the addons\web\static\src\js\data_export.js file. How to call such function from Odoo?


Parikshit Vaghasiya

--Parikshit Vaghasiya--
| 6 3 8
--Parikshit Vaghasiya--

Working as an OpenERP/Odoo developer both experience in web and addons. you can contact me at:

E-mail : parikshitvaghasiya@gmail.com

Blog : parikshitvaghasiya.blogspot.in

Stackoverflow : http://stackoverflow.com/users/5089106/parikshit-vaghasiya

Parikshit Vaghasiya
On 8/28/15, 4:13 AM


I hope this will help you. In your js file do like this :

    openerp.module_name = function(instance) {

            var QWeb = openerp.web.qweb;

            _t = instance.web._t;


            on_click_export_data: function() {

                var self = this;

                console.log('Put Your Code Here .. .. ');    

                return self._super();





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 8/27/15, 10:00 PM

Hi Tarek

The real export is done in a web controller at the url "/web/export/" followed by the specific export format. The formats available with their urls are:

openerp.addons.web.controllers.main.CSVExport used with the url "/web/export/csv"

openerp.addons.web.controllers.main.ExcelExport used with the url "/web/export/xls"

Depending of the format you need you could call the methods index or base on the corresponding class and passing the necessary arguments or finding and recreating the code for exporting the data to a file by yourself.



The export is done by odoo, why call a javascript function from odoo, if the javascript function call an odoo method. if you need export your data see the method export_data in openerp.models


    def export_data(self, fields_to_export, raw_data=False):

        """ Export fields for selected objects

            :param fields_to_export: list of fields

            :param raw_data: True to return value in native Python type

            :rtype: dictionary with a *datas* matrix

            This method is used when exporting data via client menu


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

2 follower(s)


Asked: 6/15/15, 9:11 AM
Seen: 3221 times
Last updated: 9/3/15, 8:48 PM