|
@ -3,16 +3,18 @@ odoo.define('web_export_view', function (require) { |
|
|
|
|
|
|
|
|
var core = require('web.core'); |
|
|
var core = require('web.core'); |
|
|
var Sidebar = require('web.Sidebar'); |
|
|
var Sidebar = require('web.Sidebar'); |
|
|
|
|
|
var session = require('web.session'); |
|
|
|
|
|
|
|
|
var QWeb = core.qweb; |
|
|
var QWeb = core.qweb; |
|
|
|
|
|
|
|
|
var _t = core._t; |
|
|
var _t = core._t; |
|
|
|
|
|
|
|
|
Sidebar.include({ |
|
|
Sidebar.include({ |
|
|
|
|
|
|
|
|
redraw: function () { |
|
|
|
|
|
|
|
|
_redraw: function () { |
|
|
var self = this; |
|
|
var self = this; |
|
|
this._super.apply(this, arguments); |
|
|
this._super.apply(this, arguments); |
|
|
if (self.getParent().ViewManager.active_view.type == 'list') { |
|
|
|
|
|
|
|
|
if (self.getParent().renderer.viewType == 'list') { |
|
|
self.$el.find('.o_dropdown').last().append(QWeb.render('WebExportTreeViewXls', {widget: self})); |
|
|
self.$el.find('.o_dropdown').last().append(QWeb.render('WebExportTreeViewXls', {widget: self})); |
|
|
self.$el.find('.export_treeview_xls').on('click', self.on_sidebar_export_treeview_xls); |
|
|
self.$el.find('.export_treeview_xls').on('click', self.on_sidebar_export_treeview_xls); |
|
|
} |
|
|
} |
|
@ -39,23 +41,25 @@ odoo.define('web_export_view', function (require) { |
|
|
} |
|
|
} |
|
|
var export_columns_keys = []; |
|
|
var export_columns_keys = []; |
|
|
var export_columns_names = []; |
|
|
var export_columns_names = []; |
|
|
$.each(view.visible_columns, function () { |
|
|
|
|
|
if (this.tag == 'field' && (this.widget === undefined || this.widget != 'handle')) { |
|
|
|
|
|
|
|
|
var column_index = 0; |
|
|
|
|
|
$.each(view.renderer.columns, function () { |
|
|
|
|
|
if (this.tag == 'field' && (this.attrs.widget === undefined || this.attrs.widget != 'handle')) { |
|
|
// non-fields like `_group` or buttons
|
|
|
// non-fields like `_group` or buttons
|
|
|
export_columns_keys.push(this.id); |
|
|
|
|
|
export_columns_names.push(this.string); |
|
|
|
|
|
|
|
|
export_columns_keys.push(column_index); |
|
|
|
|
|
export_columns_names.push(view.$el.find('.o_list_view > thead > tr> th[title]:eq('+column_index+')')[0].textContent); |
|
|
} |
|
|
} |
|
|
|
|
|
column_index ++; |
|
|
}); |
|
|
}); |
|
|
var export_rows = []; |
|
|
var export_rows = []; |
|
|
$.blockUI(); |
|
|
$.blockUI(); |
|
|
if (children) { |
|
|
if (children) { |
|
|
// find only rows with data
|
|
|
// find only rows with data
|
|
|
view.$el.find('.o_list_view > tbody > tr[data-id]:has(.o_list_record_selector input:checkbox:checked)') |
|
|
|
|
|
|
|
|
view.$el.find('.o_list_view > tbody > tr.o_data_row:has(.o_list_record_selector input:checkbox:checked)') |
|
|
.each(function () { |
|
|
.each(function () { |
|
|
var $row = $(this); |
|
|
var $row = $(this); |
|
|
var export_row = []; |
|
|
var export_row = []; |
|
|
$.each(export_columns_keys, function () { |
|
|
$.each(export_columns_keys, function () { |
|
|
var $cell = $row.find('td[data-field="' + this + '"]') |
|
|
|
|
|
|
|
|
var $cell = $row.find('td.o_data_cell:eq('+this+')') |
|
|
var $cellcheckbox = $cell.find('.o_checkbox input:checkbox'); |
|
|
var $cellcheckbox = $cell.find('.o_checkbox input:checkbox'); |
|
|
if ($cellcheckbox.length) { |
|
|
if ($cellcheckbox.length) { |
|
|
export_row.push( |
|
|
export_row.push( |
|
@ -85,10 +89,10 @@ odoo.define('web_export_view', function (require) { |
|
|
export_rows.push(export_row); |
|
|
export_rows.push(export_row); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
view.session.get_file({ |
|
|
|
|
|
|
|
|
session.get_file({ |
|
|
url: '/web/export/xls_view', |
|
|
url: '/web/export/xls_view', |
|
|
data: {data: JSON.stringify({ |
|
|
data: {data: JSON.stringify({ |
|
|
model: view.model, |
|
|
|
|
|
|
|
|
model: view.modelName, |
|
|
headers: export_columns_names, |
|
|
headers: export_columns_names, |
|
|
rows: export_rows |
|
|
rows: export_rows |
|
|
})}, |
|
|
})}, |
|
|