[FIX] web_widget_x2many_2d_matrix: fix totals option

Also refactored to use underscore method rather than redefining a
similar one.
pull/2361/head
Vincent Hatakeyama 2022-12-23 15:03:21 +01:00
parent c764f2d8f2
commit baa7cd2bf2
No known key found for this signature in database
GPG Key ID: 2DF8E62FCF6FB8AB
1 changed files with 4 additions and 21 deletions

View File

@ -39,8 +39,8 @@ odoo.define("web_widget_x2many_2d_matrix.widget", function (require) {
this.field_y_axis = node.field_y_axis || this.field_y_axis;
this.field_label_x_axis = node.field_label_x_axis || this.field_x_axis;
this.field_label_y_axis = node.field_label_y_axis || this.field_y_axis;
this.x_axis_clickable = this.parse_boolean(node.x_axis_clickable || "1");
this.y_axis_clickable = this.parse_boolean(node.y_axis_clickable || "1");
this.x_axis_clickable = _.str.toBool(node.x_axis_clickable || "1");
this.y_axis_clickable = _.str.toBool(node.y_axis_clickable || "1");
this.field_value = node.field_value || this.field_value;
// TODO: is this really needed? Holger?
for (var property in node) {
@ -59,17 +59,13 @@ odoo.define("web_widget_x2many_2d_matrix.widget", function (require) {
)
);
}
this.show_row_totals = this.parse_boolean(
this.show_row_totals = _.str.toBool(
node.show_row_totals ||
this.is_aggregatable(field_defs[this.field_value])
? "1"
: ""
);
this.show_column_totals = this.parse_boolean(
this.show_column_totals = _.str.toBool(
node.show_column_totals ||
this.is_aggregatable(field_defs[this.field_value])
? "1"
: ""
);
},
@ -183,19 +179,6 @@ odoo.define("web_widget_x2many_2d_matrix.widget", function (require) {
return field_def.type in {float: 1, monetary: 1, integer: 1};
},
/**
* Parse a String containing a bool and convert it to a JS bool.
*
* @param {String} val: the string to be parsed.
* @returns {Boolean} The parsed boolean.
*/
parse_boolean: function (val) {
if (val.toLowerCase() === "true" || val === "1") {
return true;
}
return false;
},
/**
* Create the matrix renderer and add its output to our element
*