mirror of https://github.com/OCA/web.git
[IMP] web_widget_x2many_2d_matrix: Total of all rows (#1043)
parent
d75b9bdf38
commit
4fea08d468
|
@ -168,6 +168,7 @@ Contributors
|
|||
* Simone Orsi <simone.orsi@camptocamp.com>
|
||||
* Timon Tschanz <timon.tschanz@camptocamp.com>
|
||||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
* Dennis Sluijk <d.sluijk@onestein.nl>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
|
|
@ -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.0.2",
|
||||
"version": "11.0.1.1.0",
|
||||
"author": "Therp BV, "
|
||||
"Tecnativa, "
|
||||
"Camptocamp, "
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
@ -304,12 +304,32 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
|
|||
_renderFooter: function () {
|
||||
var $cells = this._renderAggregateColCells();
|
||||
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.
|
||||
*
|
||||
|
@ -346,6 +366,12 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
|
|||
if (!~['integer', 'float', 'monetary'].indexOf(type)) {
|
||||
return;
|
||||
}
|
||||
this.total = {
|
||||
fname: fname,
|
||||
ftype: type,
|
||||
help: _t('Sum Total'),
|
||||
value: 0,
|
||||
};
|
||||
_.each(this.columns, function (column, index) {
|
||||
column.aggregate = {
|
||||
fname: fname,
|
||||
|
@ -361,6 +387,7 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
|
|||
// Nothing to do
|
||||
}
|
||||
});
|
||||
this.total.value += column.aggregate.value;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue