mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[FIX][web_export_view] Remove monetary formatting (#594)
Monetary fields were being exported empty because the parsing failed. In the way of correctly exporting them as numbers, this chunk of code's performance has been improved.
This commit is contained in:
committed by
Pedro M. Baeza
parent
b97b8d2788
commit
7c40582b2d
@@ -46,49 +46,45 @@ odoo.define('web_export_view', function (require) {
|
|||||||
export_columns_names.push(this.string);
|
export_columns_names.push(this.string);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var rows = view.$el.find('.o_list_view > tbody > tr');
|
|
||||||
var export_rows = [];
|
var export_rows = [];
|
||||||
$.each(rows, function () {
|
$.blockUI();
|
||||||
var $row = $(this);
|
if (children) {
|
||||||
// find only rows with data
|
// find only rows with data
|
||||||
if ($row.attr('data-id')) {
|
view.$el.find('.o_list_view > tbody > tr[data-id]:has(.o_list_record_selector input:checkbox:checked)')
|
||||||
|
.each(function () {
|
||||||
|
var $row = $(this);
|
||||||
var export_row = [];
|
var export_row = [];
|
||||||
var checked = $row.find('.o_list_record_selector input[type=checkbox]').is(':checked');
|
$.each(export_columns_keys, function () {
|
||||||
if (children && checked === true) {
|
var $cell = $row.find('td[data-field="' + this + '"]')
|
||||||
$.each(export_columns_keys, function () {
|
var $cellcheckbox = $cell.find('.o_checkbox input:checkbox');
|
||||||
var $cell = $row.find('td[data-field="' + this + '"]')
|
if ($cellcheckbox.length) {
|
||||||
var $cellcheckbox = $cell.find('.o_checkbox input[type=checkbox]');
|
export_row.push(
|
||||||
if ($cellcheckbox.length) {
|
$cellcheckbox.is(":checked")
|
||||||
if ($cellcheckbox.is(':checked')) {
|
? _t("True") : _t("False")
|
||||||
export_row.push(_t("True"));
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
export_row.push(_t("False"));
|
var text = $cell.text().trim();
|
||||||
}
|
if ($cell.hasClass("o_list_number")) {
|
||||||
|
export_row.push(parseFloat(
|
||||||
|
text
|
||||||
|
// Remove thousands separator
|
||||||
|
.split(_t.database.parameters.thousands_sep)
|
||||||
|
.join("")
|
||||||
|
// Always use a `.` as decimal separator
|
||||||
|
.replace(_t.database.parameters.decimal_point, ".")
|
||||||
|
// Remove non-numeric characters
|
||||||
|
.replace(/[^\d\.-]/g, "")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var cell = $cell.get(0);
|
export_row.push(text);
|
||||||
var text = cell.text || cell.textContent || cell.innerHTML || "";
|
|
||||||
|
|
||||||
if (cell.classList.contains("o_list_number")) {
|
|
||||||
var tmp2 = text;
|
|
||||||
do {
|
|
||||||
var tmp = tmp2;
|
|
||||||
tmp2 = tmp.replace(_t.database.parameters.thousands_sep, "");
|
|
||||||
} while (tmp !== tmp2);
|
|
||||||
tmp2 = tmp.replace(_t.database.parameters.decimal_point, ".");
|
|
||||||
export_row.push(parseFloat(tmp2));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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({
|
||||||
|
|||||||
Reference in New Issue
Block a user