Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][web_export_view] Remove monetary formatting #594

Merged
merged 2 commits into from
Mar 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions web_export_view/static/src/js/web_export_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,45 @@ odoo.define('web_export_view', function (require) {
export_columns_names.push(this.string);
}
});
var rows = view.$el.find('.o_list_view > tbody > tr');
var export_rows = [];
$.each(rows, function () {
var $row = $(this);
$.blockUI();
if (children) {
// 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 checked = $row.find('.o_list_record_selector input[type=checkbox]').is(':checked');
if (children && checked === true) {
$.each(export_columns_keys, function () {
var $cell = $row.find('td[data-field="' + this + '"]')
var $cellcheckbox = $cell.find('.o_checkbox input[type=checkbox]');
if ($cellcheckbox.length) {
if ($cellcheckbox.is(':checked')) {
export_row.push(_t("True"));
}
else {
export_row.push(_t("False"));
}
$.each(export_columns_keys, function () {
var $cell = $row.find('td[data-field="' + this + '"]')
var $cellcheckbox = $cell.find('.o_checkbox input:checkbox');
if ($cellcheckbox.length) {
export_row.push(
$cellcheckbox.is(":checked")
? _t("True") : _t("False")
);
}
else {
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 {
var cell = $cell.get(0);
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_row.push(text);
}
});
export_rows.push(export_row);
}
}
});
$.blockUI();
}
});
export_rows.push(export_row);
});
}
view.session.get_file({
url: '/web/export/xls_view',
data: {data: JSON.stringify({
Expand Down