Browse Source

add option to set a label for total column

pull/1285/head
Vincent Hatakeyama 6 years ago
parent
commit
a82480c385
  1. 3
      web_widget_x2many_2d_matrix/README.rst
  2. 2
      web_widget_x2many_2d_matrix/__manifest__.py
  3. 19
      web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js
  4. 2
      web_widget_x2many_2d_matrix/static/src/js/widget_x2many_2d_matrix.js

3
web_widget_x2many_2d_matrix/README.rst

@ -67,6 +67,9 @@ field_value
show_row_totals
If field_value is a numeric field, it indicates if you want to calculate
row totals. True by default
label_row_totals
If show_row_totals is True, this will allow to set a column label for the
totals column. Default to ''.
show_column_totals
If field_value is a numeric field, it indicates if you want to calculate
column totals. True by default

2
web_widget_x2many_2d_matrix/__manifest__.py

@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "2D matrix for x2many fields",
"version": "11.0.1.1.2",
"version": "11.0.1.1.3",
"author": "Therp BV, "
"Tecnativa, "
"Camptocamp, "

19
web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js

@ -111,10 +111,25 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
this.columns,
this._renderHeaderCell.bind(this)
));
$tr.append(this._renderHeaderSpecial());
return $('<thead>').append($tr);
},
/**
* Render the special headers of our matrix, like totals
*
* @private
* @returns {jQueryElement} a list of elements
*/
_renderHeaderSpecial: function () {
var ths = [];
if (this.matrix_data.show_row_totals) {
$tr.append($('<th/>', {class: 'total'}));
var $th = $('<th>', {class: 'total text-right'});
// label_row_totals contains either something or ''
$th.append(this.matrix_data.label_row_totals).append('</th>');
ths.push($th);
}
return $('<thead>').append($tr);
return ths;
},
/**

2
web_widget_x2many_2d_matrix/static/src/js/widget_x2many_2d_matrix.js

@ -61,6 +61,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
node.field_editability || this.field_editability;
this.show_row_totals =
this.parse_boolean(node.show_row_totals || '1');
this.label_row_totals = node.label_row_totals || '';
this.show_column_totals =
this.parse_boolean(node.show_column_totals || '1');
},
@ -108,6 +109,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
'columns': this.columns,
'rows': this.rows,
'show_row_totals': this.show_row_totals,
'label_row_totals': this.label_row_totals,
'show_column_totals': this.show_column_totals,
};
},

Loading…
Cancel
Save