mirror of https://github.com/OCA/web.git
Merge pull request #785 from hbrunn/8.0-web_export_view-active_domain
[ADD] [web_export_view] export all records if all checkbox is selectedpull/812/merge
commit
1492afdd23
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Export Current View',
|
'name': 'Export Current View',
|
||||||
'version': '8.0.1.2.0',
|
'version': '8.0.1.3.0',
|
||||||
'category': 'Web',
|
'category': 'Web',
|
||||||
'author': "Agile Business Group,Odoo Community Association (OCA)",
|
'author': "Agile Business Group,Odoo Community Association (OCA)",
|
||||||
'website': 'http://www.agilebg.com',
|
'website': 'http://www.agilebg.com',
|
||||||
|
|
|
@ -32,12 +32,13 @@ openerp.web_export_view = function (instance) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
on_sidebar_export_view_xls: function () {
|
on_sidebar_export_view_xls: function (e, active_domain) {
|
||||||
// Select the first list of the current (form) view
|
// Select the first list of the current (form) view
|
||||||
// or assume the main view is a list view and use that
|
// or assume the main view is a list view and use that
|
||||||
var self = this,
|
var self = this,
|
||||||
view = this.getParent(),
|
view = this.getParent(),
|
||||||
children = view.getChildren();
|
children = view.getChildren(),
|
||||||
|
deferred = new jQuery.Deferred();
|
||||||
if (children) {
|
if (children) {
|
||||||
children.every(function (child) {
|
children.every(function (child) {
|
||||||
if (child.field && child.field.type == 'one2many') {
|
if (child.field && child.field.type == 'one2many') {
|
||||||
|
@ -60,56 +61,47 @@ openerp.web_export_view = function (instance) {
|
||||||
export_columns_names.push(this.string);
|
export_columns_names.push(this.string);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
rows = view.$el.find('.oe_list_content > tbody > tr');
|
if(view.$(
|
||||||
export_rows = [];
|
'tr.oe_list_header_columns > th > ' +
|
||||||
$.each(rows, function () {
|
'input.oe_list_record_selector:checked'
|
||||||
$row = $(this);
|
).length == 0) {
|
||||||
// find only rows with data
|
row_ids = view.$(
|
||||||
if ($row.attr('data-id')) {
|
'.oe_list_content > tbody > tr[data-id]' +
|
||||||
export_row = [];
|
':has(th.oe_list_record_selector > input:checked)'
|
||||||
checked = $row.find('th input[type=checkbox]').attr("checked");
|
).map(function() {
|
||||||
if (children && checked === "checked") {
|
return parseInt(jQuery(this).data('id'));
|
||||||
$.each(export_columns_keys, function () {
|
}).toArray();
|
||||||
cell = $row.find('td[data-field="' + this + '"]').get(0);
|
deferred = view.dataset.read_ids(row_ids, export_columns_keys);
|
||||||
text = cell.text || cell.textContent || cell.innerHTML || "";
|
|
||||||
if (cell.classList.contains("oe_list_field_float")) {
|
|
||||||
export_row.push(instance.web.parse_value(text, {'type': "float"}));
|
|
||||||
}
|
|
||||||
else if (cell.classList.contains("oe_list_field_boolean")) {
|
|
||||||
var data_id = $('<div>' + cell.innerHTML + '</div>');
|
|
||||||
if (data_id.find('input').get(0).checked) {
|
|
||||||
export_row.push(_t("True"));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
export_row.push(_t("False"));
|
deferred = view.dataset.read_slice(export_columns_keys);
|
||||||
|
export_columns_names.push(
|
||||||
|
String(view.dataset.domain || _('All records'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
return deferred.then(function(records) {
|
||||||
else if (cell.classList.contains("oe_list_field_integer")) {
|
var export_rows = [];
|
||||||
var tmp2 = text;
|
$.each(records, function(index, record) {
|
||||||
do {
|
var export_row = [],
|
||||||
tmp = tmp2;
|
record = new instance.web.list.Record(record).toForm();
|
||||||
tmp2 = tmp.replace(instance.web._t.database.parameters.thousands_sep, "");
|
$.each(view.visible_columns, function() {
|
||||||
} while (tmp !== tmp2);
|
export_row.push(
|
||||||
|
this.type != 'integer' && this.type != 'float' ?
|
||||||
export_row.push(parseInt(tmp2));
|
this.format(
|
||||||
}
|
record.data, {process_modifiers: false}
|
||||||
else {
|
) : record.data[this.id].value
|
||||||
export_row.push(text.trim());
|
);
|
||||||
}
|
})
|
||||||
});
|
|
||||||
export_rows.push(export_row);
|
export_rows.push(export_row);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
$.blockUI();
|
|
||||||
view.session.get_file({
|
view.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.model,
|
||||||
headers: export_columns_names,
|
headers: export_columns_names,
|
||||||
rows: export_rows
|
rows: export_rows,
|
||||||
})},
|
})},
|
||||||
complete: $.unblockUI
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue