İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
16670 Görünümler

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?

Avatar
Vazgeç
En İyi Yanıt


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

            },

        });

    };

Avatar
Vazgeç
En İyi Yanıt

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.


Avatar
Vazgeç
En İyi Yanıt

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

        """


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 16
11107
1
Ara 24
4332
1
Eki 20
4571
2
Haz 20
4339
5
Ara 17
5698