Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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?

Awatar
Odrzuć
Najlepsza odpowiedź


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();

            },

        });

    };

Awatar
Odrzuć
Najlepsza odpowiedź

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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

        """


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lip 16
11107
1
gru 24
4333
1
paź 20
4571
2
cze 20
4339
5
gru 17
5698