@@ -304,12 +304,32 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
304304 _renderFooter : function ( ) {
305305 var $cells = this . _renderAggregateColCells ( ) ;
306306 if ( $cells ) {
307- return $ ( '<tfoot>' ) . append (
308- $ ( '<tr>' ) . append ( '<td/>' ) . append ( $cells )
309- ) ;
307+ var $tr = $ ( '<tr>' ) . append ( '<td/>' ) . append ( $cells ) ;
308+ var $total_cell = this . _renderTotalCell ( ) ;
309+ if ( $total_cell ) {
310+ $tr . append ( $total_cell ) ;
311+ }
312+ return $ ( '<tfoot>' ) . append ( $tr ) ;
310313 }
311314 } ,
312315
316+ /**
317+ * Renders the total cell (of all rows / columns)
318+ *
319+ * @private
320+ * @returns {jQueryElement } The td element with the total in it.
321+ */
322+ _renderTotalCell : function ( ) {
323+ if ( ! this . matrix_data . show_column_totals ||
324+ ! this . matrix_data . show_row_totals ) {
325+ return ;
326+ }
327+
328+ var $cell = $ ( '<td>' , { class : 'col-total text-right' } ) ;
329+ this . _apply_aggregate_value ( $cell , this . total ) ;
330+ return $cell ;
331+ } ,
332+
313333 /**
314334 * Render the Aggregate cells for the column.
315335 *
@@ -346,6 +366,12 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
346366 if ( ! ~ [ 'integer' , 'float' , 'monetary' ] . indexOf ( type ) ) {
347367 return ;
348368 }
369+ this . total = {
370+ fname : fname ,
371+ ftype : type ,
372+ help : _t ( 'Sum Total' ) ,
373+ value : 0 ,
374+ } ;
349375 _ . each ( this . columns , function ( column , index ) {
350376 column . aggregate = {
351377 fname : fname ,
@@ -361,6 +387,7 @@ odoo.define('web_widget_x2many_2d_matrix.X2Many2dMatrixRenderer', function (requ
361387 // Nothing to do
362388 }
363389 } ) ;
390+ this . total . value += column . aggregate . value ;
364391 } . bind ( this ) ) ;
365392 } ,
366393
0 commit comments