mirror of https://github.com/OCA/web.git
[IMP] web_widget_x2many_2d_matrix: Total of all rows (#1043)
parent
426253935e
commit
d5368b4693
|
@ -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
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -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, "
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
@ -304,10 +304,30 @@ 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(
|
var $tr = $('<tr>').append('<td/>').append($cells);
|
||||||
$('<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;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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…
Reference in New Issue