[IMP] kpi_dashboard: Compute on fly, allow to refresh data on fly

This commit is contained in:
Enric Tobella
2020-07-16 11:04:25 +02:00
parent 44565edb49
commit aa4c93b0eb
4 changed files with 53 additions and 1 deletions

View File

@@ -10,7 +10,29 @@ odoo.define('kpi_dashboard.DashboardController', function (require) {
var DashboardController = BasicController.extend({
custom_events: _.extend({}, BasicController.prototype.custom_events, {
addDashboard: '_addDashboard',
refresh_on_fly: '_refreshOnFly',
}),
_refreshOnFly: function (event) {
var self = this;
this._rpc({
model: this.modelName,
method: 'read_dashboard_on_fly',
args: [[this.renderer.state.res_id]],
context: _.extend(
{},
this.model.get(this.handle, {raw: true}).getContext(),
{bin_size: true}
),
}).then(function (data) {
_.each(data, function (item) {
// We will follow the same logic used on Bus Notifications
self.renderer._onNotification([[
"kpi_dashboard_" + self.renderer.state.res_id,
item
]])
});
});
},
renderPager: function ($node, options) {
options = _.extend({}, options, {
validate: this.canBeDiscarded.bind(this),