From 7f21258d39053a398ef8b1fed3039b879346f65a Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Fri, 5 Jun 2020 13:22:27 +0000 Subject: [FIX] web: kanban: format monetary w/o widget Before this commit, monetary fields occurring in kanban views without widget="monetary" specified weren't correctly formatted: the whitespace separating the value from the currency symbol was formatted has $nbsp; (html) instead of a simple whitespace. closes odoo/odoo#52521 Signed-off-by: Aaron Bohy (aab) Co-authored-by: Aaron Bohy --- addons/web/static/src/js/fields/field_utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 681a1eb3672..4f637994c47 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -329,13 +329,16 @@ function formatX2Many(value) { * the number of digits that should be used, instead of the default * digits precision in the field. Note: if the currency defines a * precision, the currency's one is used. + * @param {boolean} [options.html=true] + * if true, returns a string encoding the html formatted value (with + * whitespace encoded as ' ') * @returns {string} */ function formatMonetary(value, field, options) { if (value === false) { return ""; } - options = options || {}; + options = Object.assign({ html: true }, options); var currency = options.currency; if (!currency) { @@ -358,10 +361,11 @@ function formatMonetary(value, field, options) { if (!currency || options.noSymbol) { return formatted_value; } + const ws = options.html ? ' ' : ' '; if (currency.position === "after") { - return formatted_value += ' ' + currency.symbol; + return formatted_value + ws + currency.symbol; } else { - return currency.symbol + ' ' + formatted_value; + return currency.symbol + ws + formatted_value; } } /** -- cgit v1.2.3