diff --git a/web_widget_x2many_2d_matrix/README.rst b/web_widget_x2many_2d_matrix/README.rst index 52b2f3cf..e9d10d2a 100644 --- a/web_widget_x2many_2d_matrix/README.rst +++ b/web_widget_x2many_2d_matrix/README.rst @@ -168,6 +168,7 @@ Contributors * Simone Orsi * Timon Tschanz * Jairo Llopis +* Dennis Sluijk Maintainer ---------- diff --git a/web_widget_x2many_2d_matrix/__manifest__.py b/web_widget_x2many_2d_matrix/__manifest__.py index d3743de2..e0d80115 100644 --- a/web_widget_x2many_2d_matrix/__manifest__.py +++ b/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.0.2", + "version": "11.0.1.1.0", "author": "Therp BV, " "Tecnativa, " "Camptocamp, " diff --git a/web_widget_x2many_2d_matrix/static/description/screenshot.png b/web_widget_x2many_2d_matrix/static/description/screenshot.png index 922e2961..4b75baa8 100644 Binary files a/web_widget_x2many_2d_matrix/static/description/screenshot.png and b/web_widget_x2many_2d_matrix/static/description/screenshot.png differ diff --git a/web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js b/web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js index d3c98afa..6b9d6665 100644 --- a/web_widget_x2many_2d_matrix/static/src/js/2d_matrix_renderer.js +++ b/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 () { var $cells = this._renderAggregateColCells(); if ($cells) { - return $('').append( - $('').append('').append($cells) - ); + var $tr = $('').append('').append($cells); + var $total_cell = this._renderTotalCell(); + if ($total_cell) { + $tr.append($total_cell); + } + return $('').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 = $('', {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)); },