Odoo Help

Welcome!

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.

1

How to call a javascript function from Odoo

By
Tarek Mohamed Ibrahim
on 6/15/15, 9:11 AM 1,354 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?

5

Parikshit

--Parikshit--
939
| 6 3 8
Ahmedabad, India
--Parikshit--

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
On 8/28/15, 4:13 AM


Hello,

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;

        instance.web.DataExport.include({

            on_click_export_data: function() {

                var self = this;

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

                return self._super();

            },

        });

    };

1

Axel Mendoza

--Axel Mendoza--
10203
| 7 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 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.


0

Hi, 

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

    @api.multi

    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

        """


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

2 follower(s)

Stats

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