summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorHardik Prajapati <hap@odoo.com>2020-07-01 11:23:31 +0000
committerAaron Bohy <aab@odoo.com>2020-07-07 09:17:37 +0000
commit8e91b0ad3b1119b69f7a2922d1c61bb9a06529f5 (patch)
tree007f16466d1eb9c7217f22eed4faf7150231fb6e /addons/web/static/src/js
parentd5d79805d2e077c093a378cad8db1591e269305d (diff)
[FIX] web: properly display boolean fields in kanban
Before this commit, boolean fields (without widget="boolean") in kanban views were displayed as [Object object], because when no widget is specified, we display the (textual) formatted value of the field. However, the boolean formatter returns by default a string encoding an html checkbox. This commit passes the correct option to force a string formatting, so it now displays "True" or "False". Moreover, this commit uniformizes formatter options for that purpose, as another option had been recently introduced for monetary field. Note that those options should not be necessary, as formatters should always return text values (no html). But this is a larger change, that we might do in the future. Task 2280394 closes odoo/odoo#53937 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/fields/field_utils.js8
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_record.js2
2 files changed, 5 insertions, 5 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js
index 4f637994c47..b62a3db7921 100644
--- a/addons/web/static/src/js/fields/field_utils.js
+++ b/addons/web/static/src/js/fields/field_utils.js
@@ -329,8 +329,8 @@ 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
+ * @param {boolean} [options.forceString=false]
+ * if false, returns a string encoding the html formatted value (with
* whitespace encoded as '&nbsp;')
* @returns {string}
*/
@@ -338,7 +338,7 @@ function formatMonetary(value, field, options) {
if (value === false) {
return "";
}
- options = Object.assign({ html: true }, options);
+ options = Object.assign({ forceString: false }, options);
var currency = options.currency;
if (!currency) {
@@ -361,7 +361,7 @@ function formatMonetary(value, field, options) {
if (!currency || options.noSymbol) {
return formatted_value;
}
- const ws = options.html ? '&nbsp;' : ' ';
+ const ws = options.forceString ? ' ' : '&nbsp;';
if (currency.position === "after") {
return formatted_value + ws + currency.symbol;
} else {
diff --git a/addons/web/static/src/js/views/kanban/kanban_record.js b/addons/web/static/src/js/views/kanban/kanban_record.js
index b3b11a7ed54..fe24b0ebb58 100644
--- a/addons/web/static/src/js/views/kanban/kanban_record.js
+++ b/addons/web/static/src/js/views/kanban/kanban_record.js
@@ -268,7 +268,7 @@ var KanbanRecord = Widget.extend({
// it is much more efficient to use a formatter
var field = this.fields[field_name];
var value = this.recordData[field_name];
- var options = { data: this.recordData, html: false };
+ var options = { data: this.recordData, forceString: true };
var formatted_value = field_utils.format[field.type](value, field, options);
var $result = $('<span>', {
text: formatted_value,