Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web_widget_x2many_2d_matrix/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion web_widget_x2many_2d_matrix/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down
Binary file modified web_widget_x2many_2d_matrix/static/description/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 30 additions & 3 deletions web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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,
Expand All @@ -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));
},

Expand Down