From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../static/src/js/project_rating_reporting.js | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 addons/project/static/src/js/project_rating_reporting.js (limited to 'addons/project/static/src/js/project_rating_reporting.js') diff --git a/addons/project/static/src/js/project_rating_reporting.js b/addons/project/static/src/js/project_rating_reporting.js new file mode 100644 index 00000000..8e393c67 --- /dev/null +++ b/addons/project/static/src/js/project_rating_reporting.js @@ -0,0 +1,69 @@ +odoo.define('project.project_rating_reporting', function (require) { +'use strict'; + +const core = require('web.core'); +const _t = core._t; + +const viewRegistry = require('web.view_registry'); + +const PivotController = require('web.PivotController'); +const PivotView = require('web.PivotView'); + +const GraphController = require('web.GraphController'); +const GraphView = require('web.GraphView'); + +var ProjectPivotController = PivotController.extend({ + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + var measures = JSON.parse(JSON.stringify(this.measures)); + if ('res_id' in measures) { + measures.res_id.string = _t('Task'); + } + if ('parent_res_id' in measures) { + measures.parent_res_id.string = _t('Project'); + } + if ('rating' in measures) { + measures.rating.string = _t('Rating Value (/5)'); + } + this.measures = measures; + }, +}); + +var ProjectPivotView = PivotView.extend({ + config: _.extend({}, PivotView.prototype.config, { + Controller: ProjectPivotController, + }), +}); + +viewRegistry.add('project_rating_pivot', ProjectPivotView); + +var ProjectGraphController = GraphController.extend({ + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + _.each(this.measures, measure => { + if (measure.fieldName === 'res_id') { + measure.description = _t('Task'); + } else if (measure.fieldName === 'parent_res_id') { + measure.description = _t('Project'); + } else if (measure.fieldName === 'rating') { + measure.description = _t('Rating Value (/5)'); + } + }); + }, +}); + +var ProjectGraphView = GraphView.extend({ + config: _.extend({}, GraphView.prototype.config, { + Controller: ProjectGraphController, + }), +}); + +viewRegistry.add('project_rating_graph', ProjectGraphView); + +}); -- cgit v1.2.3