From b906ba08b9f64f1c25a5a39e4ebf516070f8aec3 Mon Sep 17 00:00:00 2001 From: Pierre Rousseau Date: Thu, 26 Mar 2020 07:19:21 +0000 Subject: [IMP] web: allow to add buttons to pivot controller This is useful for the integration of pivot views with spreadsheet Task-ID: 2168016 --- .../static/src/js/views/pivot/pivot_controller.js | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js index ee37aba3ce5..3eeed181795 100644 --- a/addons/web/static/src/js/views/pivot/pivot_controller.js +++ b/addons/web/static/src/js/views/pivot/pivot_controller.js @@ -91,11 +91,7 @@ odoo.define('web.PivotController', function (require) { * does nothing */ renderButtons: function ($node) { - const context = { - measures: Object.entries(this.measures) - .filter(x => x[0] !== '__count') - .sort((a, b) => a[1].string.toLowerCase() > b[1].string.toLowerCase() ? 1 : -1), - }; + const context = this._getRenderButtonContext(); this.$buttons = $(QWeb.render('PivotView.buttons', context)); this.$buttons.click(this._onButtonClick.bind(this)); this.$buttons.find('button').tooltip(); @@ -183,6 +179,30 @@ odoo.define('web.PivotController', function (require) { if ($target.hasClass('o_pivot_download')) { this._downloadTable(); } + + await this._addIncludedButtons(ev); + }, + + /** + * Declared to be overwritten in includes of pivot controller + * + * @param {MouseEvent} ev + * @returns {Promise} + * @private + */ + _addIncludedButtons: async function(ev) {}, + /** + * Get the context of rendering of the buttons + * + * @returns {Object} + * @private + */ + _getRenderButtonContext: function () { + return { + measures: Object.entries(this.measures) + .filter(x => x[0] !== '__count') + .sort((a, b) => a[1].string.toLowerCase() > b[1].string.toLowerCase() ? 1 : -1), + }; }, /** * -- cgit v1.2.3