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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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();
},
});
};
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.
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
"""
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 7 16
|
11219 | ||
|
1
thg 12 24
|
4491 | ||
|
1
thg 10 20
|
4708 | ||
|
2
thg 6 20
|
4413 | ||
|
5
thg 12 17
|
5763 |