diff --git a/README.rst b/README.rst index 614749c26742e9c0bc01c10adf4f6169585ed185..0b7a98b401e1287493e9f8765eb955297d0ace20 100644 --- a/README.rst +++ b/README.rst @@ -10,8 +10,8 @@ OACC - Visualisation des courbes Description =========== -Ce module hérite de module *oacc* et rajoute la fonctionnalité de visualisation des courbes de charges sur le BackEnd de Odoo. -Une nouvelle vue est implémentée et est accessible à partir de la page d'une opération. +Ce module hérite de module *oacc* et rajoute toutes les fonctions de visualisation des courbes et des champs calculés +affichés sur le portail. Exemple ======= @@ -22,7 +22,7 @@ Credits ======= Le développement de ce module a été financé par / The development of this module has been financially supported by: - - CLIENT (https://website-client) + - ENERCOOP (https://website-client) Contributors ------------ diff --git a/__manifest__.py b/__manifest__.py index 89f219871663bd8f48b0b8ef784e1bd3cebbde45..e1c2db1ac20bbfda18887d13254f0a5aeaccc0f2 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -7,9 +7,8 @@ "license": "AGPL-3", "depends": ["oacc"], "data": [ - "security/ir.model.access.csv", + # "security/ir.model.access.csv", # datas - "templates/acc_operation_overview_cdc.xml", # views "views/acc_operation_views.xml", # views menu @@ -21,7 +20,6 @@ "web.assets_frontend": [], "web.assets_tests": [], "web.assets_backend": [ - "oacc_overview_cdc/static/src/js/operation_graph.js", ], "web.assets_qweb": [], }, diff --git a/models/acc_operation.py b/models/acc_operation.py index 0d45933af909b0dcc4277f61ef36c119800d3173..a0fe016ce1013a3d0ca8bc9bd18a82519c6631cb 100644 --- a/models/acc_operation.py +++ b/models/acc_operation.py @@ -15,82 +15,12 @@ DEFAULT_MONTH_RANGE = 3 class AccOperation(models.Model): _inherit = "acc.operation" - def prepare_values(self): - last_record = self.get_the_last_day() - - date_day_start, date_day_end = self.get_last_day("day", last_record) - last_day = date_day_start.strftime("%d %B %Y") - date_day_start = date_day_start.strftime("%Y-%m-%d") - date_day_end = date_day_end.strftime("%Y-%m-%d") - - date_week_start, date_week_end = self.get_last_day("week", last_record) - last_week = ( - date_week_start.strftime("%d %B %Y") - + "-" - + date_week_end.strftime("%d %B %Y") - ) - date_week_start = date_week_start.strftime("%Y-%m-%d") - date_week_end = date_week_end.strftime("%Y-%m-%d") - - date_month_start, date_month_end = self.get_last_day("month", last_record) - last_month = ( - date_month_start.strftime("%d %B %Y") - + "-" - + date_month_end.strftime("%d %B %Y") - ) - date_month_start = date_month_start.strftime("%Y-%m-%d") - date_month_end = date_month_end.strftime("%Y-%m-%d") - - date_semestre_start, date_semestre_end = self.get_last_day( - "semestre", last_record - ) - last_semester = ( - date_semestre_start.strftime("%d %B %Y") - + "-" - + date_semestre_end.strftime("%d %B %Y") - ) - date_semestre_start = date_semestre_start.strftime("%Y-%m-%d") - date_semestre_end = date_semestre_end.strftime("%Y-%m-%d") - - date_year_start, date_year_end = self.get_last_day("year", last_record) - last_year = ( - date_year_start.strftime("%d %B %Y") - + "- " - + date_year_end.strftime("%d %B %Y") - ) - date_year_start = date_year_start.strftime("%Y-%m-%d") - date_year_end = date_year_end.strftime("%Y-%m-%d") - - data_values = { - "last_day": last_day, - "last_week": last_week, - "last_month": last_month, - "last_semestre": last_semester, - "last_year": last_year, - # 'range_date': range_date, - "date_day_start": date_day_start, - "date_day_end": date_day_end, - "date_week_start": date_week_start, - "date_week_end": date_week_end, - "date_month_start": date_month_start, - "date_month_end": date_month_end, - "date_semestre_start": date_semestre_start, - "date_semestre_end": date_semestre_end, - "date_year_start": date_year_start, - "date_year_end": date_year_end, - } - - return data_values - - def get_overview(self): - return self.prepare_values() - # ------------------------------------------------------ # Actions # ------------------------------------------------------ def action_view_courbes(self): """ - Action qui ouvre la vue Qweb + Action qui ouvre le portail sur l'opération :return: Vue Qweb """ self.ensure_one() @@ -104,27 +34,6 @@ class AccOperation(models.Model): # ------------------------------------------------------ # Business methods # ------------------------------------------------------ - def get_auto_power_tot(self): - """ - Fonction retournant l autoconsommation totale du dernier mois. - :return: la somme de l'autoconso totale de tous les consommateurs - """ - # Récupère les dates du dernier mois disponible - last_record = self.get_the_last_day() - date_start, date_end = self.get_last_day("month", last_record) - # Conso Totale - autoconso_ids = self.env["acc.enedis.cdc"].search( - [ - ("acc_operation_id", "=", self.id), - ("comp_data_type", "=", "autocons"), - ("date_slot", ">=", date_start), - ("date_slot", "<", date_end), - ] - ) - autoconso_tot = (sum(autoconso_ids.mapped("power")) / 1000) / 2 - - return autoconso_tot - def get_power_tot(self): """ Fonction retournant la consommation totale, l'autoconsommation totale @@ -169,18 +78,6 @@ class AccOperation(models.Model): raw_data = self.env.cr.fetchall() return raw_data[0][1], raw_data[0][2], raw_data[0][3], date_start - def get_power_install_tot(self): - """ - Fonction retournant la puissance totale installée. - :return: la somme de toutes les puissances d'injection - """ - puiss_tot = 0.0 - - for counter in self.acc_injection_ids: - puiss_tot += counter.acc_counter_id.power_instal - - return puiss_tot - def get_the_last_day(self): """ Fonction retournant la date du dernier enregistrement @@ -345,13 +242,6 @@ class AccOperation(models.Model): self.env.cr.execute(query, query_params) raw_data = self.env.cr.fetchall() for row in raw_data: - # if slot_type == "month" or slot_type == "year": - # data_autocons.append(int(row[1])) - # data_prod.append(int(row[2])) - # data_allocons.append(int(row[3])) - # data_cons.append(int(row[4])) - # label.append(row[0]) - # else: data_autocons.append({"x": row[0], "y": round(row[1], 2)}) data_prod.append({"x": row[0], "y": round(row[2], 2)}) data_allocons.append({"x": row[0], "y": round(row[3], 2)}) @@ -474,15 +364,10 @@ class AccOperation(models.Model): self.env.cr.execute(query, query_params) raw_data = self.env.cr.fetchall() for row in raw_data: - # if slot_type == "month" or slot_type == "year": - # data_autocons.append(int(row[1])) - # data_surplus.append(int(row[2])) - # label.append(row[0]) if slot_type == "day": data_autocons_histo.append(round(row[1], 2)) data_surplus_histo.append(round(row[2], 2)) label_histo.append(row[0]) - # else: data_autocons.append({"x": row[0], "y": round(row[1], 2)}) data_surplus.append({"x": row[0], "y": round(row[2], 2)}) label.append(row[0]) diff --git a/static/src/js/operation_graph.js b/static/src/js/operation_graph.js deleted file mode 100644 index a2c6057eb7512868e3d1cbd288e18562b4982159..0000000000000000000000000000000000000000 --- a/static/src/js/operation_graph.js +++ /dev/null @@ -1,277 +0,0 @@ -odoo.define("oacc_overview_cdc.operation_overview_cdc", function (require) { - "use strict"; - - var qweb = require("web.qweb"); - var viewRegistry = require("web.view_registry"); - - let chartValues = null; - const Renderer = qweb.Renderer.extend({ - events: _.extend({}, qweb.Renderer.prototype.events, { - "click .o_acc_button": "_onChartClicked", - }), - - _render: async function () { - var self = this; - var chart_line_conso; - var chart_line_prod; - var chart_donuts_conso; - var chart_donuts_prod; - var chart_histo_conso; - var chart_histo_prod; - - if (chart_line_conso !== undefined) { - chart_line_conso.destroy(); - } - if (chart_line_prod !== undefined) { - chart_line_prod.destroy(); - } - if (chart_donuts_conso !== undefined) { - chart_donuts_conso.destroy(); - } - if (chart_donuts_prod !== undefined) { - chart_donuts_prod.destroy(); - } - if (chart_histo_conso !== undefined) { - chart_histo_conso.destroy(); - } - if (chart_histo_prod !== undefined) { - chart_histo_prod.destroy(); - } - await this._super(...arguments); - - var result = self.state.chartValues; - - var line_conso = self.$el.find("#line_chart_conso"); - var donuts_conso = self.$el.find("#donuts_chart_conso"); - var histo_conso = self.$el.find("#histo_chart_conso"); - var line_prod = self.$el.find("#line_chart_prod"); - var donuts_prod = self.$el.find("#donuts_chart_prod"); - var histo_prod = self.$el.find("#histo_chart_prod"); - - if (result.scale !== "week" && result.scale !== "day") { - line_conso.hide(); - line_prod.hide(); - } - - if (result.scale === "week" || result.scale === "day") { - chart_line_conso = new Chart( - line_conso, - Object.assign({}, result.line_chart_conso_line) - ); - } - - chart_donuts_conso = new Chart( - donuts_conso, - Object.assign({}, result.donuts_chart_conso) - ); - - chart_histo_conso = new Chart( - histo_conso, - Object.assign({}, result.histo_chart_conso) - ); - - if (result.scale === "week" || result.scale === "day") { - chart_line_prod = new Chart( - line_prod, - Object.assign({}, result.line_chart_prod_line) - ); - } - - chart_donuts_prod = new Chart( - donuts_prod, - Object.assign({}, result.donuts_chart_prod) - ); - - chart_histo_prod = new Chart( - histo_prod, - Object.assign({}, result.histo_chart_prod) - ); - this.$el.find(".o_acc_button").removeClass("active"); - var $but = null; - if (this.state.scale) { - $but = this.$el.find( - '.o_acc_button[data-mode="' + this.state.scale + '"]' - ); - } else { - $but = this.$el.find('.o_acc_button[data-mode="month"]'); - } - $but.addClass("active"); - }, - - _onChartClicked: function (e) { - e.preventDefault(); - var $action = $(e.currentTarget); - $action.addClass("active"); - var context = JSON.parse($action.attr("context").replace(/'/g, '"')); - var first_day = context.first_day; - var last_day = context.last_day; - this.trigger_up("chart_open_action", { - action_name: $action.attr("name"), - action_context: $action.attr("context"), - action_first_day: first_day, - action_last_day: last_day, - }); - }, - }); - - const Model = qweb.Model.extend({ - /** - * @override - */ - init: function () { - this.chartValues = {}; - this._super.apply(this, arguments); - }, - - /** - * @override - */ - __get: function (localID) { - var result = this._super.apply(this, arguments); - if (_.isObject(result)) { - result.chartValues = this.chartValues[localID]; - } - return result; - }, - - /** - * @override - * @returns {Promise} - */ - __load: function (params) { - if ("scales" in params) { - this.scales = params.scales; - this.first_day = params.first_day; - this.last_day = params.last_day; - } - return this._loadChart(this._super.apply(this, arguments), params); - }, - /** - * @override - * @returns {Promise} - */ - __reload: function (handle, params) { - if ("scales" in params) { - this.scales = params.scales; - this.first_day = params.first_day; - this.last_day = params.last_day; - } - return this._loadChart(this._super.apply(this, arguments), params); - }, - - /** - * @private - * @param {Promise} super_def a promise that resolves with a dataPoint id - * @returns {Promise -> string} resolves to the dataPoint id - */ - _loadChart: function (super_def) { - var self = this; - var acc_counter_id = - self._state.context.search_default_acc_delivery_operation_ids; - var domain = self._state.domain; - var chart_def = this._rpc({ - model: "acc.operation", - method: "graph_view_global", - args: [ - this, - this.scales, - this.first_day, - this.last_day, - "", - acc_counter_id, - "", - ], - // Method: "graph_view", - // args: [ - // domain, - // this.scales, - // this.first_day, - // this.last_day, - // acc_counter_id, - // ], - context: this._state.context, - }); - return Promise.all([super_def, chart_def]).then(function (results) { - var id = results[0]; - chartValues = results[1]; - self.chartValues[id] = chartValues; - return id; - }); - }, - - setScale: function (scale) { - this.scales = scale; - }, - - setDate: function (first_day, last_day) { - this.first_day = first_day; - this.last_day = last_day; - }, - }); - - const Controller = qweb.Controller.extend({ - custom_events: _.extend({}, qweb.Controller.prototype.custom_events, { - chart_open_action: "_onChartClicked", - cal_open_action: "_onCalClicked", - }), - - init: function (parent, model, renderer, params) { - this._super.apply(this, arguments); - this.scales = params.scales; - this.first_day = params.first_day; - this.last_day = params.last_day; - }, - - /** - * @private - * @param {OdooEvent} e - */ - _onChartClicked: function (e) { - this.model.setScale(e.data.action_name); - this.model.setDate(e.data.action_first_day, e.data.action_last_day); - var state = this.model.get(); - state.scale = e.data.action_name; - state.first_day = e.data.action_first_day; - state.last_day = e.data.action_last_day; - this.reload(); - }, - - /** - * @private - * @param {OdooEvent} e - */ - _onCalClicked: function (e) { - var state = this.model.get(); - state.date_start = e.data.date_start; - state.date_end = e.data.date_end; - this.reload(); - }, - }); - - var OperationGraph = qweb.View.extend({ - withSearchBar: true, - searchMenuTypes: ["filter", "favorite"], - jsLibs: [ - "/web/static/lib/Chart/Chart.js", - "/oacc_overview_cdc/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js", - "/web/static/lib/moment/moment.js", - ], - config: _.extend({}, qweb.View.prototype.config, { - Model: Model, - Renderer: Renderer, - Controller: Controller, - }), - - init: function () { - this._super.apply(this, arguments); - this.controllerParams.scales = "month"; - this.loadParams.scales = "month"; - this.controllerParams.first_day = ""; - this.controllerParams.last_day = ""; - this.loadParams.first_day = ""; - this.loadParams.last_day = ""; - }, - }); - - viewRegistry.add("operation_overview_cdc", OperationGraph); -}); diff --git a/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js b/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js deleted file mode 100644 index e27a91318cd70e39f6a6f0405825d1d428ffebb4..0000000000000000000000000000000000000000 --- a/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js +++ /dev/null @@ -1,860 +0,0 @@ -/* ! - * chartjs-plugin-datalabels v1.0.0 - * https://chartjs-plugin-datalabels.netlify.app - * (c) 2017-2021 chartjs-plugin-datalabels contributors - * Released under the MIT license - */ -!(function (t, e) { - typeof exports === "object" && typeof module !== "undefined" - ? (module.exports = e(require("chart.js"))) - : typeof define === "function" && define.amd - ? define(["chart.js"], e) - : ((t = - typeof globalThis !== "undefined" - ? globalThis - : t || self).ChartDataLabels = e(t.Chart)); -})(this, function (t) { - "use strict"; - function e(t) { - return t && typeof t === "object" && "default" in t ? t : {default: t}; - } - var r = e(t), - n = r.default.helpers, - a = (function () { - if (typeof window !== "undefined") { - if (window.devicePixelRatio) return window.devicePixelRatio; - var t = window.screen; - if (t) return (t.deviceXDPI || 1) / (t.logicalXDPI || 1); - } - return 1; - })(), - i = { - toTextLines: function (t) { - var e, - r = []; - for (t = [].concat(t); t.length; ) - typeof (e = t.pop()) === "string" - ? r.unshift.apply(r, e.split("\n")) - : Array.isArray(e) - ? t.push.apply(t, e) - : n.isNullOrUndef(t) || r.unshift(String(e)); - return r; - }, - toFontString: function (t) { - return !t || n.isNullOrUndef(t.size) || n.isNullOrUndef(t.family) - ? null - : (t.style ? t.style + " " : "") + - (t.weight ? t.weight + " " : "") + - t.size + - "px " + - t.family; - }, - textSize: function (t, e, r) { - var n, - a = [].concat(e), - i = a.length, - o = t.font, - l = 0; - for (t.font = r.string, n = 0; n < i; ++n) - l = Math.max(t.measureText(a[n]).width, l); - return (t.font = o), {height: i * r.lineHeight, width: l}; - }, - parseFont: function (t) { - var e = r.default.defaults.global, - a = n.valueOrDefault(t.size, e.defaultFontSize), - o = { - family: n.valueOrDefault(t.family, e.defaultFontFamily), - lineHeight: n.options.toLineHeight(t.lineHeight, a), - size: a, - style: n.valueOrDefault(t.style, e.defaultFontStyle), - weight: n.valueOrDefault(t.weight, null), - string: "", - }; - return (o.string = i.toFontString(o)), o; - }, - bound: function (t, e, r) { - return Math.max(t, Math.min(e, r)); - }, - arrayDiff: function (t, e) { - var r, - n, - a, - i, - o = t.slice(), - l = []; - for (r = 0, a = e.length; r < a; ++r) - (i = e[r]), - (n = o.indexOf(i)) === -1 ? l.push([i, 1]) : o.splice(n, 1); - for (r = 0, a = o.length; r < a; ++r) l.push([o[r], -1]); - return l; - }, - rasterize: function (t) { - return Math.round(t * a) / a; - }, - }; - function o(t, e) { - var r = e.x, - n = e.y; - if (r === null) return {x: 0, y: -1}; - if (n === null) return {x: 1, y: 0}; - var a = t.x - r, - i = t.y - n, - o = Math.sqrt(a * a + i * i); - return {x: o ? a / o : 0, y: o ? i / o : -1}; - } - function l(t, e, r) { - var n = 0; - return ( - t < r.left ? (n |= 1) : t > r.right && (n |= 2), - e < r.top ? (n |= 8) : e > r.bottom && (n |= 4), - n - ); - } - function s(t, e) { - var r, - n, - a = e.anchor, - i = t; - return ( - e.clamp && - (i = (function (t, e) { - for ( - var r, - n, - a, - i = t.x0, - o = t.y0, - s = t.x1, - u = t.y1, - d = l(i, o, e), - f = l(s, u, e); - d | f && !(d & f); - - ) - 8 & (r = d || f) - ? ((n = i + ((s - i) * (e.top - o)) / (u - o)), (a = e.top)) - : 4 & r - ? ((n = i + ((s - i) * (e.bottom - o)) / (u - o)), - (a = e.bottom)) - : 2 & r - ? ((a = o + ((u - o) * (e.right - i)) / (s - i)), - (n = e.right)) - : 1 & r && - ((a = o + ((u - o) * (e.left - i)) / (s - i)), - (n = e.left)), - r === d - ? (d = l((i = n), (o = a), e)) - : (f = l((s = n), (u = a), e)); - return {x0: i, x1: s, y0: o, y1: u}; - })(i, e.area)), - a === "start" - ? ((r = i.x0), (n = i.y0)) - : a === "end" - ? ((r = i.x1), (n = i.y1)) - : ((r = (i.x0 + i.x1) / 2), (n = (i.y0 + i.y1) / 2)), - (function (t, e, r, n, a) { - switch (a) { - case "center": - r = n = 0; - break; - case "bottom": - (r = 0), (n = 1); - break; - case "right": - (r = 1), (n = 0); - break; - case "left": - (r = -1), (n = 0); - break; - case "top": - (r = 0), (n = -1); - break; - case "start": - (r = -r), (n = -n); - break; - case "end": - break; - default: - (a *= Math.PI / 180), (r = Math.cos(a)), (n = Math.sin(a)); - } - return {x: t, y: e, vx: r, vy: n}; - })(r, n, t.vx, t.vy, e.align) - ); - } - var u = function (t, e) { - var r = (t.startAngle + t.endAngle) / 2, - n = Math.cos(r), - a = Math.sin(r), - i = t.innerRadius, - o = t.outerRadius; - return s( - { - x0: t.x + n * i, - y0: t.y + a * i, - x1: t.x + n * o, - y1: t.y + a * o, - vx: n, - vy: a, - }, - e - ); - }, - d = function (t, e) { - var r = o(t, e.origin), - n = r.x * t.radius, - a = r.y * t.radius; - return s( - {x0: t.x - n, y0: t.y - a, x1: t.x + n, y1: t.y + a, vx: r.x, vy: r.y}, - e - ); - }, - f = function (t, e) { - var r = o(t, e.origin), - n = t.x, - a = t.y, - i = 0, - l = 0; - return ( - t.horizontal - ? ((n = Math.min(t.x, t.base)), (i = Math.abs(t.base - t.x))) - : ((a = Math.min(t.y, t.base)), (l = Math.abs(t.base - t.y))), - s({x0: n, y0: a + l, x1: n + i, y1: a, vx: r.x, vy: r.y}, e) - ); - }, - c = function (t, e) { - var r = o(t, e.origin); - return s({x0: t.x, y0: t.y, x1: t.x, y1: t.y, vx: r.x, vy: r.y}, e); - }, - h = r.default.helpers, - x = i.rasterize; - function y(t) { - var e = t._model.horizontal, - r = t._scale || (e && t._xScale) || t._yScale; - if (!r) return null; - if (void 0 !== r.xCenter && void 0 !== r.yCenter) - return {x: r.xCenter, y: r.yCenter}; - var n = r.getBasePixel(); - return e ? {x: n, y: null} : {x: null, y: n}; - } - function v(t, e, r) { - var n = t.shadowBlur, - a = r.stroked, - i = x(r.x), - o = x(r.y), - l = x(r.w); - a && t.strokeText(e, i, o, l), - r.filled && - (n && a && (t.shadowBlur = 0), - t.fillText(e, i, o, l), - n && a && (t.shadowBlur = n)); - } - var b = function (t, e, r, n) { - var a = this; - (a._config = t), - (a._index = n), - (a._model = null), - (a._rects = null), - (a._ctx = e), - (a._el = r); - }; - h.extend(b.prototype, { - _modelize: function (t, e, n, a) { - var o, - l = this, - s = l._index, - x = h.options.resolve, - v = i.parseFont(x([n.font, {}], a, s)), - b = x([n.color, r.default.defaults.global.defaultFontColor], a, s); - return { - align: x([n.align, "center"], a, s), - anchor: x([n.anchor, "center"], a, s), - area: a.chart.chartArea, - backgroundColor: x([n.backgroundColor, null], a, s), - borderColor: x([n.borderColor, null], a, s), - borderRadius: x([n.borderRadius, 0], a, s), - borderWidth: x([n.borderWidth, 0], a, s), - clamp: x([n.clamp, !1], a, s), - clip: x([n.clip, !1], a, s), - color: b, - display: t, - font: v, - lines: e, - offset: x([n.offset, 0], a, s), - opacity: x([n.opacity, 1], a, s), - origin: y(l._el), - padding: h.options.toPadding(x([n.padding, 0], a, s)), - positioner: - ((o = l._el), - o instanceof r.default.elements.Arc - ? u - : o instanceof r.default.elements.Point - ? d - : o instanceof r.default.elements.Rectangle - ? f - : c), - rotation: x([n.rotation, 0], a, s) * (Math.PI / 180), - size: i.textSize(l._ctx, e, v), - textAlign: x([n.textAlign, "start"], a, s), - textShadowBlur: x([n.textShadowBlur, 0], a, s), - textShadowColor: x([n.textShadowColor, b], a, s), - textStrokeColor: x([n.textStrokeColor, b], a, s), - textStrokeWidth: x([n.textStrokeWidth, 0], a, s), - }; - }, - update: function (t) { - var e, - r, - n, - a = this, - o = null, - l = null, - s = a._index, - u = a._config, - d = h.options.resolve([u.display, !0], t, s); - d && - ((e = t.dataset.data[s]), - (r = h.valueOrDefault(h.callback(u.formatter, [e, t]), e)), - (n = h.isNullOrUndef(r) ? [] : i.toTextLines(r)).length && - (l = (function (t) { - var e = t.borderWidth || 0, - r = t.padding, - n = t.size.height, - a = t.size.width, - i = -a / 2, - o = -n / 2; - return { - frame: { - x: i - r.left - e, - y: o - r.top - e, - w: a + r.width + 2 * e, - h: n + r.height + 2 * e, - }, - text: {x: i, y: o, w: a, h: n}, - }; - })((o = a._modelize(d, n, u, t))))), - (a._model = o), - (a._rects = l); - }, - geometry: function () { - return this._rects ? this._rects.frame : {}; - }, - rotation: function () { - return this._model ? this._model.rotation : 0; - }, - visible: function () { - return this._model && this._model.opacity; - }, - model: function () { - return this._model; - }, - draw: function (t, e) { - var r, - n = t.ctx, - a = this._model, - o = this._rects; - this.visible() && - (n.save(), - a.clip && - ((r = a.area), - n.beginPath(), - n.rect(r.left, r.top, r.right - r.left, r.bottom - r.top), - n.clip()), - (n.globalAlpha = i.bound(0, a.opacity, 1)), - n.translate(x(e.x), x(e.y)), - n.rotate(a.rotation), - (function (t, e, r) { - var n = r.backgroundColor, - a = r.borderColor, - i = r.borderWidth; - (n || (a && i)) && - (t.beginPath(), - h.canvas.roundedRect( - t, - x(e.x) + i / 2, - x(e.y) + i / 2, - x(e.w) - i, - x(e.h) - i, - r.borderRadius - ), - t.closePath(), - n && ((t.fillStyle = n), t.fill()), - a && - i && - ((t.strokeStyle = a), - (t.lineWidth = i), - (t.lineJoin = "miter"), - t.stroke())); - })(n, o.frame, a), - (function (t, e, r, n) { - var a, - i = n.textAlign, - o = n.color, - l = Boolean(o), - s = n.font, - u = e.length, - d = n.textStrokeColor, - f = n.textStrokeWidth, - c = d && f; - if (u && (l || c)) - for ( - r = (function (t, e, r) { - var n = r.lineHeight, - a = t.w, - i = t.x; - return ( - e === "center" - ? (i += a / 2) - : (e !== "end" && e !== "right") || (i += a), - {h: n, w: a, x: i, y: t.y + n / 2} - ); - })(r, i, s), - t.font = s.string, - t.textAlign = i, - t.textBaseline = "middle", - t.shadowBlur = n.textShadowBlur, - t.shadowColor = n.textShadowColor, - l && (t.fillStyle = o), - c && - ((t.lineJoin = "round"), - (t.lineWidth = f), - (t.strokeStyle = d)), - a = 0, - u = e.length; - a < u; - ++a - ) - v(t, e[a], { - stroked: c, - filled: l, - w: r.w, - x: r.x, - y: r.y + r.h * a, - }); - })(n, a.lines, o.text, a), - n.restore()); - }, - }); - var _ = r.default.helpers, - p = Number.MIN_SAFE_INTEGER || -9007199254740991, - g = Number.MAX_SAFE_INTEGER || 9007199254740991; - function m(t, e, r) { - var n = Math.cos(r), - a = Math.sin(r), - i = e.x, - o = e.y; - return { - x: i + n * (t.x - i) - a * (t.y - o), - y: o + a * (t.x - i) + n * (t.y - o), - }; - } - function w(t, e) { - var r, - n, - a, - i, - o, - l = g, - s = p, - u = e.origin; - for (r = 0; r < t.length; ++r) - (a = (n = t[r]).x - u.x), - (i = n.y - u.y), - (o = e.vx * a + e.vy * i), - (l = Math.min(l, o)), - (s = Math.max(s, o)); - return {min: l, max: s}; - } - function k(t, e) { - var r = e.x - t.x, - n = e.y - t.y, - a = Math.sqrt(r * r + n * n); - return {vx: (e.x - t.x) / a, vy: (e.y - t.y) / a, origin: t, ln: a}; - } - var M = function () { - (this._rotation = 0), (this._rect = {x: 0, y: 0, w: 0, h: 0}); - }; - function S(t, e, r) { - var n = e.positioner(t, e), - a = n.vx, - i = n.vy; - if (!a && !i) return {x: n.x, y: n.y}; - var o = r.w, - l = r.h, - s = e.rotation, - u = Math.abs((o / 2) * Math.cos(s)) + Math.abs((l / 2) * Math.sin(s)), - d = Math.abs((o / 2) * Math.sin(s)) + Math.abs((l / 2) * Math.cos(s)), - f = 1 / Math.max(Math.abs(a), Math.abs(i)); - return ( - (u *= a * f), - (d *= i * f), - (u += e.offset * a), - (d += e.offset * i), - {x: n.x + u, y: n.y + d} - ); - } - _.extend(M.prototype, { - center: function () { - var t = this._rect; - return {x: t.x + t.w / 2, y: t.y + t.h / 2}; - }, - update: function (t, e, r) { - (this._rotation = r), - (this._rect = {x: e.x + t.x, y: e.y + t.y, w: e.w, h: e.h}); - }, - contains: function (t) { - var e = this, - r = e._rect; - return !( - (t = m(t, e.center(), -e._rotation)).x < r.x - 1 || - t.y < r.y - 1 || - t.x > r.x + r.w + 2 || - t.y > r.y + r.h + 2 - ); - }, - intersects: function (t) { - var e, - r, - n, - a = this._points(), - i = t._points(), - o = [k(a[0], a[1]), k(a[0], a[3])]; - for ( - this._rotation !== t._rotation && o.push(k(i[0], i[1]), k(i[0], i[3])), - e = 0; - e < o.length; - ++e - ) - if ( - ((r = w(a, o[e])), (n = w(i, o[e])), r.max < n.min || n.max < r.min) - ) - return !1; - return !0; - }, - _points: function () { - var t = this, - e = t._rect, - r = t._rotation, - n = t.center(); - return [ - m({x: e.x, y: e.y}, n, r), - m({x: e.x + e.w, y: e.y}, n, r), - m({x: e.x + e.w, y: e.y + e.h}, n, r), - m({x: e.x, y: e.y + e.h}, n, r), - ]; - }, - }); - var $ = { - prepare: function (t) { - var e, - r, - n, - a, - i, - o = []; - for (e = 0, n = t.length; e < n; ++e) - for (r = 0, a = t[e].length; r < a; ++r) - (i = t[e][r]), - o.push(i), - (i.$layout = { - _box: new M(), - _hidable: !1, - _visible: !0, - _set: e, - _idx: r, - }); - return ( - o.sort(function (t, e) { - var r = t.$layout, - n = e.$layout; - return r._idx === n._idx ? n._set - r._set : n._idx - r._idx; - }), - this.update(o), - o - ); - }, - update: function (t) { - var e, - r, - n, - a, - i, - o = !1; - for (e = 0, r = t.length; e < r; ++e) - (a = (n = t[e]).model()), - ((i = n.$layout)._hidable = a && a.display === "auto"), - (i._visible = n.visible()), - (o |= i._hidable); - o && - (function (t) { - var e, r, n, a, i, o; - for (e = 0, r = t.length; e < r; ++e) - (a = (n = t[e]).$layout)._visible && - ((i = n.geometry()), - (o = S(n._el._model, n.model(), i)), - a._box.update(o, i, n.rotation())); - (function (t, e) { - var r, n, a, i; - for (r = t.length - 1; r >= 0; --r) - for ( - a = t[r].$layout, n = r - 1; - n >= 0 && a._visible; - --n - ) - (i = t[n].$layout)._visible && - a._box.intersects(i._box) && - e(a, i); - })(t, function (t, e) { - var r = t._hidable, - n = e._hidable; - (r && n) || n ? (e._visible = !1) : r && (t._visible = !1); - }); - })(t); - }, - lookup: function (t, e) { - var r, n; - for (r = t.length - 1; r >= 0; --r) - if ((n = t[r].$layout) && n._visible && n._box.contains(e)) - return t[r]; - return null; - }, - draw: function (t, e) { - var r, n, a, i, o, l; - for (r = 0, n = e.length; r < n; ++r) - (i = (a = e[r]).$layout)._visible && - ((o = a.geometry()), - (l = S(a._el._view, a.model(), o)), - i._box.update(l, o, a.rotation()), - a.draw(t, l)); - }, - }, - C = r.default.helpers, - z = { - align: "center", - anchor: "center", - backgroundColor: null, - borderColor: null, - borderRadius: 0, - borderWidth: 0, - clamp: !1, - clip: !1, - color: void 0, - display: !0, - font: { - family: void 0, - lineHeight: 1.2, - size: void 0, - style: void 0, - weight: null, - }, - formatter: function (t) { - if (C.isNullOrUndef(t)) return null; - var e, - r, - n, - a = t; - if (C.isObject(t)) - if (C.isNullOrUndef(t.label)) - if (C.isNullOrUndef(t.r)) - for ( - a = "", n = 0, r = (e = Object.keys(t)).length; - n < r; - ++n - ) - a += (n !== 0 ? ", " : "") + e[n] + ": " + t[e[n]]; - else a = t.r; - else a = t.label; - return String(a); - }, - labels: void 0, - listeners: {}, - offset: 4, - opacity: 1, - padding: {top: 4, right: 4, bottom: 4, left: 4}, - rotation: 0, - textAlign: "start", - textStrokeColor: void 0, - textStrokeWidth: 0, - textShadowBlur: 0, - textShadowColor: void 0, - }, - A = r.default.helpers, - O = "$default"; - function D(t, e, r) { - if (e) { - var n, - a = r.$context, - i = r.$groups; - e[i._set] && - (n = e[i._set][i._key]) && - !0 === A.callback(n, [a]) && - ((t.$datalabels._dirty = !0), r.update(a)); - } - } - function N(t, e) { - var r, - n, - a = t.$datalabels, - i = a._listeners; - if (i.enter || i.leave) { - if (e.type === "mousemove") n = $.lookup(a._labels, e); - else if (e.type !== "mouseout") return; - (r = a._hovered), - (a._hovered = n), - (function (t, e, r, n) { - var a, i; - (r || n) && - (r ? (n ? r !== n && (i = a = !0) : (i = !0)) : (a = !0), - i && D(t, e.leave, r), - a && D(t, e.enter, n)); - })(t, i, r, n); - } - } - return ( - (r.default.defaults.global.plugins.datalabels = z), - { - id: "datalabels", - beforeInit: function (t) { - t.$datalabels = {_actives: []}; - }, - beforeUpdate: function (t) { - var e = t.$datalabels; - (e._listened = !1), - (e._listeners = {}), - (e._datasets = []), - (e._labels = []); - }, - afterDatasetUpdate: function (t, e, r) { - var n, - a, - i, - o, - l, - s, - u, - d, - f = e.index, - c = t.$datalabels, - h = (c._datasets[f] = []), - x = t.isDatasetVisible(f), - y = t.data.datasets[f], - v = (function (t, e) { - var r, - n, - a, - i = t.datalabels, - o = []; - return !1 === i - ? null - : (!0 === i && (i = {}), - (e = A.merge({}, [e, i])), - (n = e.labels || {}), - (a = Object.keys(n)), - delete e.labels, - a.length - ? a.forEach(function (t) { - n[t] && - o.push(A.merge({}, [e, n[t], {_key: t}])); - }) - : o.push(e), - (r = o.reduce(function (t, e) { - return ( - A.each(e.listeners || {}, function (r, n) { - (t[n] = t[n] || {}), (t[n][e._key || O] = r); - }), - delete e.listeners, - t - ); - }, {})), - {labels: o, listeners: r}); - })(y, r), - _ = e.meta.data || [], - p = t.ctx; - for (p.save(), n = 0, i = _.length; n < i; ++n) - if ( - (((u = _[n]).$datalabels = []), - x && u && !u.hidden && !u._model.skip) - ) - for (a = 0, o = v.labels.length; a < o; ++a) - (s = (l = v.labels[a])._key), - ((d = new b(l, p, u, n)).$groups = { - _set: f, - _key: s || O, - }), - (d.$context = { - active: !1, - chart: t, - dataIndex: n, - dataset: y, - datasetIndex: f, - }), - d.update(d.$context), - u.$datalabels.push(d), - h.push(d); - p.restore(), - A.merge(c._listeners, v.listeners, { - merger: function (t, r, n) { - (r[t] = r[t] || {}), - (r[t][e.index] = n[t]), - (c._listened = !0); - }, - }); - }, - afterUpdate: function (t, e) { - t.$datalabels._labels = $.prepare(t.$datalabels._datasets, e); - }, - afterDatasetsDraw: function (t) { - $.draw(t, t.$datalabels._labels); - }, - beforeEvent: function (t, e) { - if (t.$datalabels._listened) - switch (e.type) { - case "mousemove": - case "mouseout": - N(t, e); - break; - case "click": - !(function (t, e) { - var r = t.$datalabels, - n = r._listeners.click, - a = n && $.lookup(r._labels, e); - a && D(t, n, a); - })(t, e); - } - }, - afterEvent: function (t) { - var e, - n, - a, - o, - l, - s, - u, - d = t.$datalabels, - f = d._actives, - c = (d._actives = t.lastActive || []), - h = i.arrayDiff(f, c); - for (e = 0, n = h.length; e < n; ++e) - if ((l = h[e])[1]) - for (a = 0, o = (u = l[0].$datalabels || []).length; a < o; ++a) - ((s = u[a]).$context.active = l[1] === 1), - s.update(s.$context); - (d._dirty || h.length) && - ($.update(d._labels), - (function (t) { - if (!t.animating) { - for ( - var e = r.default.animationService.animations, - n = 0, - a = e.length; - n < a; - ++n - ) - if (e[n].chart === t) return; - t.render({duration: 1, lazy: !0}); - } - })(t)), - delete d._dirty; - }, - } - ); -}); diff --git a/views/acc_operation_views.xml b/views/acc_operation_views.xml index ab9865896c52d4e6898aa2b8f399551e6903f104..d9773946b463d836e1f8ae4c94ccbf6c8745c009 100644 --- a/views/acc_operation_views.xml +++ b/views/acc_operation_views.xml @@ -17,10 +17,4 @@ </field> </record> - <record id="acc_operation_action_client_courbes" model="ir.actions.act_window"> - <field name="name">Voir les courbes</field> - <field name="res_model">acc.operation</field> - <field name="view_mode">qweb</field> - </record> - </odoo>