diff --git a/kpi_dashboard/__manifest__.py b/kpi_dashboard/__manifest__.py
index 9dc410d2..9f7567af 100644
--- a/kpi_dashboard/__manifest__.py
+++ b/kpi_dashboard/__manifest__.py
@@ -5,7 +5,7 @@
"name": "Kpi Dashboard",
"summary": """
Create Dashboards using kpis""",
- "version": "13.0.1.0.0",
+ "version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
diff --git a/kpi_dashboard/demo/demo_dashboard.xml b/kpi_dashboard/demo/demo_dashboard.xml
index 83aa515a..7b04070a 100644
--- a/kpi_dashboard/demo/demo_dashboard.xml
+++ b/kpi_dashboard/demo/demo_dashboard.xml
@@ -13,18 +13,14 @@
$
code
number
-
-result = {"value": 10000,"previous": 12000}
-
+ result = {"value": 10000,"previous": 12000}
Number 02
€
code
number
-
-result = {"value": 12000,"previous": 10000}
-
+ result = {"value": 12000,"previous": 10000}
€
code
meter
-
-result = {"min": 0, "max": 100, "value": 90}
-
+ result = {"min": 0, "max": 100, "value": 90}
Meter 02
$
code
meter
-
-result = {"min": 0, "max": 100, "value": 40}
-
+ result = {"min": 0, "max": 100, "value": 40}
Graph
code
graph
-
+
+ ]]>
@@ -89,18 +83,22 @@ result = {"graphs": [
code
integer
-
+
+ ]]>
Counter
code
counter
-
+
+ ]]>
Dashboard title
@@ -161,13 +159,13 @@ result = {"value": self.env.context.get('counter', 990)}
#B41F1F
#EEBF77
- {'counter': (context.counter or 990) + 1}
+
+ {'counter': (context.counter or 990) + 1}
+
- check_if(((context.counter or 990) + 1) % 2, '#ff0000', '#00ff00')
+
+ check_if(((context.counter or 990) + 1) % 2, '#ff0000', '#00ff00')
+
Counter
diff --git a/kpi_dashboard/models/ir_actions_act_window_view.py b/kpi_dashboard/models/ir_actions_act_window_view.py
index ad2a2a8c..c0e96fc7 100644
--- a/kpi_dashboard/models/ir_actions_act_window_view.py
+++ b/kpi_dashboard/models/ir_actions_act_window_view.py
@@ -7,4 +7,6 @@ from odoo import fields, models
class IrActionsActWindowView(models.Model):
_inherit = "ir.actions.act_window.view"
- view_mode = fields.Selection(selection_add=[("dashboard", "Dashboard")])
+ view_mode = fields.Selection(
+ selection_add=[("dashboard", "Dashboard")], ondelete={"dashboard": "cascade"}
+ )
diff --git a/kpi_dashboard/models/ir_ui_view.py b/kpi_dashboard/models/ir_ui_view.py
index 6c4e3273..f0d8fdb5 100644
--- a/kpi_dashboard/models/ir_ui_view.py
+++ b/kpi_dashboard/models/ir_ui_view.py
@@ -7,4 +7,6 @@ from odoo import fields, models
class IrUiView(models.Model):
_inherit = "ir.ui.view"
- type = fields.Selection(selection_add=[("dashboard", "Dashboard")])
+ type = fields.Selection(
+ selection_add=[("dashboard", "Dashboard")], ondelete={"dashboard": "cascade"}
+ )
diff --git a/kpi_dashboard/models/kpi_dashboard.py b/kpi_dashboard/models/kpi_dashboard.py
index c03073ab..20642ed3 100644
--- a/kpi_dashboard/models/kpi_dashboard.py
+++ b/kpi_dashboard/models/kpi_dashboard.py
@@ -11,9 +11,13 @@ class KpiDashboard(models.Model):
_description = "Dashboard"
name = fields.Char(required=True)
- active = fields.Boolean(default=True,)
+ active = fields.Boolean(
+ default=True,
+ )
item_ids = fields.One2many(
- "kpi.dashboard.item", inverse_name="dashboard_id", copy=True,
+ "kpi.dashboard.item",
+ inverse_name="dashboard_id",
+ copy=True,
)
number_of_columns = fields.Integer(default=5, required=True)
compute_on_fly_refresh = fields.Integer(
@@ -25,7 +29,9 @@ class KpiDashboard(models.Model):
widget_dimension_x = fields.Integer(default=250, required=True)
widget_dimension_y = fields.Integer(default=250, required=True)
background_color = fields.Char(required=True, default="#f9f9f9")
- group_ids = fields.Many2many("res.groups",)
+ group_ids = fields.Many2many(
+ "res.groups",
+ )
menu_id = fields.Many2one("ir.ui.menu", copy=False)
def write(self, vals):
@@ -227,3 +233,6 @@ class KpiDashboardItem(models.Model):
"kpi_dashboard.kpi_dashboard_item_config_form_view"
).id,
}
+
+ def store_data(self):
+ return {"type": "ir.actions.act_window_close"}
diff --git a/kpi_dashboard/models/kpi_kpi.py b/kpi_dashboard/models/kpi_kpi.py
index 90d340b4..12c72d52 100644
--- a/kpi_dashboard/models/kpi_kpi.py
+++ b/kpi_dashboard/models/kpi_kpi.py
@@ -2,9 +2,9 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import ast
-import datetime
import json
import re
+from datetime import date, datetime, time
from dateutil import relativedelta
@@ -24,11 +24,15 @@ class KpiKpi(models.Model):
active = fields.Boolean(default=True)
cron_id = fields.Many2one("ir.cron", readonly=True, copy=False)
computation_method = fields.Selection(
- [("function", "Function"), ("code", "Code")], required=True
+ [("function", "Function"), ("code", "Code")],
+ required=True,
+ default="code",
)
value = fields.Serialized()
dashboard_item_ids = fields.One2many("kpi.dashboard.item", inverse_name="kpi_id")
- model_id = fields.Many2one("ir.model",)
+ model_id = fields.Many2one(
+ "ir.model",
+ )
function = fields.Char()
args = fields.Char()
kwargs = fields.Char()
@@ -144,6 +148,8 @@ class KpiKpi(models.Model):
"self": self,
"model": self.browse(),
"datetime": datetime,
+ "date": date,
+ "time": time,
"float_compare": float_compare,
"relativedelta": relativedelta.relativedelta,
}
@@ -231,6 +237,7 @@ class KpiKpiHistory(models.Model):
widget = fields.Selection(
selection=lambda self: self.env["kpi.kpi"]._fields["widget"].selection,
required=True,
+ default="number",
)
@api.depends("value")
diff --git a/kpi_dashboard/security/ir.model.access.csv b/kpi_dashboard/security/ir.model.access.csv
index 8dacb37e..51698bc7 100644
--- a/kpi_dashboard/security/ir.model.access.csv
+++ b/kpi_dashboard/security/ir.model.access.csv
@@ -9,3 +9,4 @@ manage_kpi_dashboard_kpi,manage_kpi_dashboard_kpi,model_kpi_dashboard_item,group
manage_kpi_kpi,manage_kpi_kpi,model_kpi_kpi,group_kpi_dashboard_manager,1,1,1,1
manage_kpi_kpi_action,manage_kpi_kpi_action,model_kpi_kpi_action,group_kpi_dashboard_manager,1,1,1,1
manage_kpi_kpi_history,manage_kpi_kpi_history,model_kpi_kpi_history,group_kpi_dashboard_manager,1,1,1,1
+access_kpi_dashboard_menu,access_kpi_dashboard_menu,model_kpi_dashboard_menu,group_kpi_dashboard_manager,1,1,1,1
diff --git a/kpi_dashboard/security/security.xml b/kpi_dashboard/security/security.xml
index dd87e7c2..4ed1d841 100644
--- a/kpi_dashboard/security/security.xml
+++ b/kpi_dashboard/security/security.xml
@@ -9,9 +9,10 @@
KPI Dashboard: User
- ['|', ('group_ids', '=', False), ('group_ids', 'in', user.groups_id.ids)]
+
+ ['|', ('group_ids', '=', False), ('group_ids', 'in',
+ user.groups_id.ids)]
+
diff --git a/kpi_dashboard/static/src/js/dashboard_controller.js b/kpi_dashboard/static/src/js/dashboard_controller.js
index bf6e5554..e433bd07 100644
--- a/kpi_dashboard/static/src/js/dashboard_controller.js
+++ b/kpi_dashboard/static/src/js/dashboard_controller.js
@@ -1,7 +1,7 @@
/*
global py
*/
-odoo.define("kpi_dashboard.DashboardController", function(require) {
+odoo.define("kpi_dashboard.DashboardController", function (require) {
"use strict";
var BasicController = require("web.BasicController");
@@ -11,7 +11,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
var _t = core._t;
var DashboardController = BasicController.extend({
- init: function() {
+ init: function () {
this._super.apply(this, arguments);
this.dashboard_context = {};
this.dashboard_color_data = [];
@@ -23,15 +23,15 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
add_modify_color: "_addModifyColor",
refresh_colors: "_refreshColors",
}),
- _refreshOnFly: function() {
+ _refreshOnFly: function () {
var self = this;
this._rpc({
model: this.modelName,
method: "read_dashboard_on_fly",
args: [[this.renderer.state.res_id]],
context: this._getContext(),
- }).then(function(data) {
- _.each(data, function(item) {
+ }).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],
@@ -39,21 +39,21 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
});
});
},
- renderPager: function($node, options) {
+ renderPager: function ($node, options) {
// eslint-disable-next-line no-param-reassign
options = _.extend({}, options, {
validate: this.canBeDiscarded.bind(this),
});
this._super($node, options);
},
- _pushState: function(state) {
+ _pushState: function (state) {
// eslint-disable-next-line no-param-reassign
state = state || {};
var env = this.model.get(this.handle, {env: true});
state.id = env.currentId;
this._super(state);
},
- _addDashboard: function() {
+ _addDashboard: function () {
var self = this;
var action = self.initialState.specialData.action_id;
var name = self.initialState.specialData.name;
@@ -71,7 +71,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
name: name,
},
})
- .then(function(r) {
+ .then(function (r) {
if (r) {
self.do_notify(
_.str.sprintf(_t("'%s' added to dashboard"), name),
@@ -84,7 +84,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
}
});
},
- _updateButtons: function() {
+ _updateButtons: function () {
// HOOK Function
this.$buttons.on(
"click",
@@ -92,7 +92,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._addDashboard.bind(this)
);
},
- renderButtons: function($node) {
+ renderButtons: function ($node) {
if (!$node) {
return;
}
@@ -103,7 +103,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._updateButtons();
this.$buttons.appendTo($node);
},
- _getContext: function() {
+ _getContext: function () {
return _.extend(
{},
this.model.get(this.handle, {raw: true}).getContext(),
@@ -111,7 +111,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this.dashboard_context
);
},
- _modifyContext: function(event) {
+ _modifyContext: function (event) {
var ctx = this._getContext();
this.dashboard_context = _.extend(
this.dashboard_context,
@@ -119,7 +119,7 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
context: _.extend(
ctx,
{
- __getattr__: function() {
+ __getattr__: function () {
return false;
},
}
@@ -131,23 +131,23 @@ odoo.define("kpi_dashboard.DashboardController", function(require) {
this._refreshOnFly(event);
this._refreshColors();
},
- _addModifyColor: function(event) {
+ _addModifyColor: function (event) {
this.dashboard_color_data.push([
event.data.element_id,
event.data.expression,
]);
},
- _refreshColors: function() {
+ _refreshColors: function () {
var self = this;
var ctx = this._getContext();
- _.each(this.dashboard_color_data, function(data) {
+ _.each(this.dashboard_color_data, function (data) {
var color = py.eval(data[1], {
context: _.extend(ctx, {
- __getattr__: function() {
+ __getattr__: function () {
return false;
},
}),
- check_if: function(args) {
+ check_if: function (args) {
if (args[0].toJSON()) {
return args[1];
}
diff --git a/kpi_dashboard/static/src/js/dashboard_model.js b/kpi_dashboard/static/src/js/dashboard_model.js
index bd15e643..368e22fe 100644
--- a/kpi_dashboard/static/src/js/dashboard_model.js
+++ b/kpi_dashboard/static/src/js/dashboard_model.js
@@ -1,16 +1,16 @@
-odoo.define("kpi_dashboard.DashboardModel", function(require) {
+odoo.define("kpi_dashboard.DashboardModel", function (require) {
"use strict";
var BasicModel = require("web.BasicModel");
var DashboardModel = BasicModel.extend({
- _fetchRecord: function(record) {
+ _fetchRecord: function (record) {
return this._rpc({
model: record.model,
method: "read_dashboard",
args: [[record.res_id]],
context: _.extend({}, record.getContext(), {bin_size: true}),
- }).then(function(result) {
+ }).then(function (result) {
record.specialData = result;
return result;
});
diff --git a/kpi_dashboard/static/src/js/dashboard_renderer.js b/kpi_dashboard/static/src/js/dashboard_renderer.js
index 823831e5..0a080c4a 100644
--- a/kpi_dashboard/static/src/js/dashboard_renderer.js
+++ b/kpi_dashboard/static/src/js/dashboard_renderer.js
@@ -1,4 +1,4 @@
-odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
+odoo.define("kpi_dashboard.DashboardRenderer", function (require) {
"use strict";
var BasicRenderer = require("web.BasicRenderer");
@@ -8,25 +8,25 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
var DashboardRenderer = BasicRenderer.extend({
className: "o_dashboard_view",
- _getDashboardWidget: function(kpi) {
+ _getDashboardWidget: function (kpi) {
var Widget = registry.getAny([kpi.widget, "abstract"]);
var widget = new Widget(this, kpi);
return widget;
},
- _onClickModifyContext: function(modify_context_expression, event) {
+ _onClickModifyContext: function (modify_context_expression, event) {
this.trigger_up("modify_context", {
context: modify_context_expression,
event: event,
});
},
- _renderView: function() {
+ _renderView: function () {
this.$el.html($(qweb.render("dashboard_kpi.dashboard")));
this.$el.css("background-color", this.state.specialData.background_color);
this.$el.find(".gridster").css("width", this.state.specialData.width);
this.$grid = this.$el.find(".gridster ul");
var self = this;
this.kpi_widget = {};
- _.each(this.state.specialData.item_ids, function(kpi) {
+ _.each(this.state.specialData.item_ids, function (kpi) {
var element = $(qweb.render("kpi_dashboard.kpi", {widget: kpi}));
element.css("background-color", kpi.color);
element.css("color", kpi.font_color);
@@ -72,7 +72,7 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
this.call("bus_service", "onNotification", this, this._onNotification);
if (this.state.specialData.compute_on_fly_refresh > 0) {
// Setting the refresh interval
- this.on_fly_interval = setInterval(function() {
+ this.on_fly_interval = setInterval(function () {
self.trigger_up("refresh_on_fly");
}, this.state.specialData.compute_on_fly_refresh * 1000);
}
@@ -82,16 +82,16 @@ odoo.define("kpi_dashboard.DashboardRenderer", function(require) {
// context
return $.when();
},
- on_detach_callback: function() {
+ on_detach_callback: function () {
// We want to clear the refresh interval once we exit the view
if (this.on_fly_interval) {
clearInterval(this.on_fly_interval);
}
this._super.apply(this, arguments);
},
- _onNotification: function(notifications) {
+ _onNotification: function (notifications) {
var self = this;
- _.each(notifications, function(notification) {
+ _.each(notifications, function (notification) {
var channel = notification[0];
var message = notification[1];
if (channel === self.channel && message) {
diff --git a/kpi_dashboard/static/src/js/dashboard_view.js b/kpi_dashboard/static/src/js/dashboard_view.js
index e83dc991..114fd061 100644
--- a/kpi_dashboard/static/src/js/dashboard_view.js
+++ b/kpi_dashboard/static/src/js/dashboard_view.js
@@ -1,4 +1,4 @@
-odoo.define("kpi_dashboard.DashboardView", function(require) {
+odoo.define("kpi_dashboard.DashboardView", function (require) {
"use strict";
var BasicView = require("web.BasicView");
@@ -24,7 +24,7 @@ odoo.define("kpi_dashboard.DashboardView", function(require) {
}),
multi_record: false,
searchable: false,
- init: function() {
+ init: function () {
this._super.apply(this, arguments);
this.controllerParams.mode = "readonly";
this.loadParams.type = "record";
diff --git a/kpi_dashboard/static/src/js/field_widget.js b/kpi_dashboard/static/src/js/field_widget.js
index 3c9a6140..00454f34 100644
--- a/kpi_dashboard/static/src/js/field_widget.js
+++ b/kpi_dashboard/static/src/js/field_widget.js
@@ -1,4 +1,4 @@
-odoo.define("kpi_dashboard.KpiFieldWidget", function(require) {
+odoo.define("kpi_dashboard.KpiFieldWidget", function (require) {
"use strict";
var basic_fields = require("web.basic_fields");
@@ -11,7 +11,7 @@ odoo.define("kpi_dashboard.KpiFieldWidget", function(require) {
jsLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.js"],
cssLibs: ["/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css"],
className: "o_dashboard_view",
- _renderReadonly: function() {
+ _renderReadonly: function () {
this.$el.html($(qweb.render("dashboard_kpi.dashboard")));
var marginx = 0;
var marginy = 0;
diff --git a/kpi_dashboard/static/src/js/lib/nvd3.js b/kpi_dashboard/static/src/js/lib/nvd3.js
index e27fe602..3d638c33 100644
--- a/kpi_dashboard/static/src/js/lib/nvd3.js
+++ b/kpi_dashboard/static/src/js/lib/nvd3.js
@@ -1,7 +1,7 @@
/*
global nv
*/
-odoo.define("web.nvd3.extensions", function() {
+odoo.define("web.nvd3.extensions", function () {
"use strict";
/**
@@ -16,7 +16,7 @@ odoo.define("web.nvd3.extensions", function() {
// see https://github.com/novus/nvd3/pull/396 for more details
// Adds a resize listener to the window.
- nv.utils.onWindowResize = function(fun) {
+ nv.utils.onWindowResize = function (fun) {
if (fun === null) return;
window.addEventListener("resize", fun);
};
@@ -25,7 +25,7 @@ odoo.define("web.nvd3.extensions", function() {
nv.utils.windowResize = nv.utils.onWindowResize;
// Removes a resize listener from the window.
- nv.utils.offWindowResize = function(fun) {
+ nv.utils.offWindowResize = function (fun) {
if (fun === null) return;
window.removeEventListener("resize", fun);
};
@@ -33,7 +33,7 @@ odoo.define("web.nvd3.extensions", function() {
// Monkey patch nvd3 to prevent crashes when user changes view and nvd3
// tries to remove tooltips after 500 ms... seriously nvd3, what were you
// thinking?
- nv.tooltip.cleanup = function() {
+ nv.tooltip.cleanup = function () {
$(".nvtooltip").remove();
};
@@ -41,7 +41,7 @@ odoo.define("web.nvd3.extensions", function() {
// with a negative `top`; with this patch the highest tooltip's position is
// still in the graph
var originalCalcTooltipPosition = nv.tooltip.calcTooltipPosition;
- nv.tooltip.calcTooltipPosition = function() {
+ nv.tooltip.calcTooltipPosition = function () {
var container = originalCalcTooltipPosition.apply(this, arguments);
container.style.top =
container.style.top.split("px")[0] < 0 ? 0 + "px" : container.style.top;
diff --git a/kpi_dashboard/static/src/js/widget/abstract_widget.js b/kpi_dashboard/static/src/js/widget/abstract_widget.js
index 22ee823c..8a77db90 100644
--- a/kpi_dashboard/static/src/js/widget/abstract_widget.js
+++ b/kpi_dashboard/static/src/js/widget/abstract_widget.js
@@ -1,4 +1,4 @@
-odoo.define("kpi_dashboard.AbstractWidget", function(require) {
+odoo.define("kpi_dashboard.AbstractWidget", function (require) {
"use strict";
var Widget = require("web.Widget");
var field_utils = require("web.field_utils");
@@ -17,7 +17,7 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
"click .o_kpi_dashboard_toggle_button": "_onClickToggleButton",
"click .direct_action": "_onClickDirectAction",
},
- init: function(parent, kpi_values) {
+ init: function (parent, kpi_values) {
this._super(parent);
this.col = kpi_values.col;
this.row = kpi_values.row;
@@ -37,21 +37,21 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
this.widget_size_y =
this.widget_dimension_y * this.sizey + (this.sizey - 1) * this.margin_y;
},
- willStart: function() {
+ willStart: function () {
// We need to load the libraries before the start
return $.when(ajax.loadLibs(this), this._super.apply(this, arguments));
},
- start: function() {
+ start: function () {
var self = this;
- return this._super.apply(this, arguments).then(function() {
+ return this._super.apply(this, arguments).then(function () {
self._fillWidget(self.values);
});
},
- _onClickToggleButton: function(event) {
+ _onClickToggleButton: function (event) {
event.preventDefault();
this.$el.toggleClass("o_dropdown_open");
},
- _fillWidget: function(values) {
+ _fillWidget: function (values) {
// This function fills the widget values
if (this.$el === undefined) return;
this.fillWidget(values);
@@ -73,20 +73,20 @@ odoo.define("kpi_dashboard.AbstractWidget", function(require) {
if ($manage && this.showManagePanel(values))
$manage.toggleClass("hidden", false);
},
- showManagePanel: function(values) {
+ showManagePanel: function (values) {
// Hook for extensions
return values.actions !== undefined;
},
- fillWidget: function(values) {
+ fillWidget: function (values) {
// Specific function that will be changed by specific widget
var value = values.value;
var self = this;
- _.each(value, function(val, key) {
+ _.each(value, function (val, key) {
var item = self.$el.find("[data-bind=" + key + "]");
if (item) item.text(val);
});
},
- _onClickDirectAction: function(event) {
+ _onClickDirectAction: function (event) {
event.preventDefault();
var $data = $(event.currentTarget).closest("a");
var action = this.actions[$($data).data("id")];
diff --git a/kpi_dashboard/static/src/js/widget/counter_widget.js b/kpi_dashboard/static/src/js/widget/counter_widget.js
index 54d7f8cc..6a37b710 100644
--- a/kpi_dashboard/static/src/js/widget/counter_widget.js
+++ b/kpi_dashboard/static/src/js/widget/counter_widget.js
@@ -1,4 +1,4 @@
-odoo.define("kpi_dashboard.CounterWidget", function(require) {
+odoo.define("kpi_dashboard.CounterWidget", function (require) {
"use strict";
var IntegerWidget = require("kpi_dashboard.IntegerWidget");
diff --git a/kpi_dashboard/static/src/js/widget/graph_widget.js b/kpi_dashboard/static/src/js/widget/graph_widget.js
index 91820b4b..a6871acd 100644
--- a/kpi_dashboard/static/src/js/widget/graph_widget.js
+++ b/kpi_dashboard/static/src/js/widget/graph_widget.js
@@ -1,7 +1,7 @@
/*
global nv, d3
*/
-odoo.define("kpi_dashboard.GraphWidget", function(require) {
+odoo.define("kpi_dashboard.GraphWidget", function (require) {
"use strict";
var AbstractWidget = require("kpi_dashboard.AbstractWidget");
@@ -17,12 +17,12 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
"/kpi_dashboard/static/src/js/lib/nvd3.js",
],
cssLibs: ["/kpi_dashboard/static/lib/nvd3/nv.d3.css"],
- start: function() {
+ start: function () {
this._onResize = this._onResize.bind(this);
nv.utils.windowResize(this._onResize);
return this._super.apply(this, arguments);
},
- destroy: function() {
+ destroy: function () {
if ("nv" in window && nv.utils && nv.utils.offWindowResize) {
// If the widget is destroyed before the lazy loaded libs (nv) are
// actually loaded (i.e. after the widget has actually started),
@@ -31,9 +31,9 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
}
this._super.apply(this, arguments);
},
- _getChartOptions: function() {
+ _getChartOptions: function () {
return {
- x: function(d, u) {
+ x: function (d, u) {
return u;
},
margin: {left: 0, right: 0, top: 5, bottom: 0},
@@ -44,11 +44,11 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
width: this.widget_size_x - 20,
};
},
- _chartConfiguration: function(values) {
+ _chartConfiguration: function (values) {
this.chart.forceY([0]);
- this.chart.xAxis.tickFormat(function(d) {
+ this.chart.xAxis.tickFormat(function (d) {
var label = "";
- _.each(values.value.graphs, function(v) {
+ _.each(values.value.graphs, function (v) {
if (v.values[d] && v.values[d].x) {
label = v.values[d].x;
}
@@ -57,7 +57,7 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
});
this.chart.yAxis.tickFormat(d3.format(",.2f"));
- this.chart.tooltip.contentGenerator(function(key) {
+ this.chart.tooltip.contentGenerator(function (key) {
return qweb.render("GraphCustomTooltip", {
color: key.point.color,
key: key.series[0].title,
@@ -65,7 +65,7 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
});
});
},
- _addGraph: function(values) {
+ _addGraph: function (values) {
var data = values.value.graphs;
this.$svg.addClass("o_graph_linechart");
this.chart = nv.models.lineChart();
@@ -79,23 +79,23 @@ odoo.define("kpi_dashboard.GraphWidget", function(require) {
this.$("svg").css("height", this.widget_size_y - 90);
this._customizeChart();
},
- fillWidget: function(values) {
+ fillWidget: function (values) {
var self = this;
var element = this.$el.find('[data-bind="value"]');
element.empty();
element.css("padding-left", 10).css("padding-right", 10);
this.chart = null;
- nv.addGraph(function() {
+ nv.addGraph(function () {
self.$svg = self.$el
.find('[data-bind="value"]')
.append("