Browse Source

[IMP] web_widget_x2many_2d_matrix: Total of all rows (#1043)

pull/1106/head
Dennis Sluijk 6 years ago
committed by Jairo Llopis
parent
commit
58e22f173f
  1. 1
      web_widget_x2many_2d_matrix/README.rst
  2. 2
      web_widget_x2many_2d_matrix/__manifest__.py
  3. BIN
      web_widget_x2many_2d_matrix/static/description/screenshot.png
  4. 33
      web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js

1
web_widget_x2many_2d_matrix/README.rst

@ -168,6 +168,7 @@ Contributors
* Simone Orsi <simone.orsi@camptocamp.com> * Simone Orsi <simone.orsi@camptocamp.com>
* Timon Tschanz <timon.tschanz@camptocamp.com> * Timon Tschanz <timon.tschanz@camptocamp.com>
* Jairo Llopis <jairo.llopis@tecnativa.com> * Jairo Llopis <jairo.llopis@tecnativa.com>
* Dennis Sluijk <d.sluijk@onestein.nl>
Maintainer Maintainer
---------- ----------

2
web_widget_x2many_2d_matrix/__manifest__.py

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

BIN
web_widget_x2many_2d_matrix/static/description/screenshot.png

Before

Width: 1240  |  Height: 471  |  Size: 22 KiB

After

Width: 1466  |  Height: 497  |  Size: 24 KiB

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

@ -304,12 +304,32 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
_renderFooter: function () { _renderFooter: function () {
var $cells = this._renderAggregateColCells(); var $cells = this._renderAggregateColCells();
if ($cells) { if ($cells) {
return $('<tfoot>').append(
$('<tr>').append('<td/>').append($cells)
);
var $tr = $('<tr>').append('<td/>').append($cells);
var $total_cell = this._renderTotalCell();
if ($total_cell) {
$tr.append($total_cell);
}
return $('<tfoot>').append($tr);
} }
}, },
/**
* Renders the total cell (of all rows / columns)
*
* @private
* @returns {jQueryElement} The td element with the total in it.
*/
_renderTotalCell: function() {
if (!this.matrix_data.show_column_totals ||
!this.matrix_data.show_row_totals) {
return;
}
var $cell = $('<td>', {class: 'col-total text-right'});
this._apply_aggregate_value($cell, this.total);
return $cell;
},
/** /**
* Render the Aggregate cells for the column. * Render the Aggregate cells for the column.
* *
@ -346,6 +366,12 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
if (!~['integer', 'float', 'monetary'].indexOf(type)) { if (!~['integer', 'float', 'monetary'].indexOf(type)) {
return; return;
} }
this.total = {
fname: fname,
ftype: type,
help: _t('Sum Total'),
value: 0,
};
_.each(this.columns, function (column, index) { _.each(this.columns, function (column, index) {
column.aggregate = { column.aggregate = {
fname: fname, fname: fname,
@ -361,6 +387,7 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
// Nothing to do // Nothing to do
} }
}); });
this.total.value += column.aggregate.value;
}.bind(this)); }.bind(this));
}, },

Loading…
Cancel
Save