diff --git a/project_lifeline/README.rst b/project_lifeline/README.rst new file mode 100644 index 000000000..ee7b6c83a --- /dev/null +++ b/project_lifeline/README.rst @@ -0,0 +1,26 @@ +Lifeline for Task +================= + +This module aims to automatically update the color of the progressbar in task form. +LifeLine progressbar is calculated based on live time and given deadline time. + +Features +======== + +* User Defined Progress Bar Colour Configuration. +* Task Lifeline Bar based on Deadline. +* Automatic Colour Change of Lifeline Bar. +* Default Colour for Forbidden. + + + .. note:: + + A new menu is created under Project-configuration where + >set color for percentage range. + + It effects the task form view Life line progress bar + + +Credits +======= +Developer: Nilmar Shereef @ cybrosys, shereef@cybrosys.in diff --git a/project_lifeline/__init__.py b/project_lifeline/__init__.py new file mode 100644 index 000000000..b2462eb50 --- /dev/null +++ b/project_lifeline/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import models diff --git a/project_lifeline/__manifest__.py b/project_lifeline/__manifest__.py new file mode 100644 index 000000000..934d97a87 --- /dev/null +++ b/project_lifeline/__manifest__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': "Lifeline for Task", + 'summary': """Lifeline Progressbar for Tasks (100% -> 0%)""", + 'description': """Calculates the time remaining based on live time & deadline.""", + 'author': 'Cybrosys Techno Solutions', + 'website': "http://www.cybrosys.com", + 'company': 'Cybrosys Techno Solutions', + 'category': 'Project', + 'version': '0.2', + 'depends': ['base', 'project'], + 'data': [ + 'views/task_lifeline_view.xml', + 'views/progress_bar_view.xml', + 'views/progress_bar_settings.xml', + ], + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, +} diff --git a/project_lifeline/models/__init__.py b/project_lifeline/models/__init__.py new file mode 100644 index 000000000..c9c2a95fb --- /dev/null +++ b/project_lifeline/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import task_lifeline +import progress_bar_color diff --git a/project_lifeline/models/progress_bar_color.py b/project_lifeline/models/progress_bar_color.py new file mode 100644 index 000000000..07491f6dc --- /dev/null +++ b/project_lifeline/models/progress_bar_color.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo import models, fields, api, exceptions, _ + + +class SelectColor(models.Model): + _name = "set.progressbar.color" + _rec_name = 'color' + + range_start = fields.Integer(string='Range From(%)', required=True, help="Starting range of Statusbar in Percentage") + range_stop = fields.Integer(string='Range To(%)', required=True, help="Stop range of Statusbar in Percentage") + color = fields.Selection([('red', 'Red'), ('green', 'Green'), ('yellow', 'Yellow'), + ('pink', 'Pink'), ('orange', 'Orange'), + ('light_green', 'Light Green'), ('grey', 'Grey'), + ('blue', 'Blue'), ('purple', 'Purple'), + ('black', 'Black'), ('brown', 'Brown')], + string='Color', required=True, default='red', + help="Choose a color for selected range") + + @api.multi + def assign_progress_bar_color(self): + values = self.env['set.progressbar.color'].search([]) + list_ret = [] + for value in values: + list_temp = [] + list_temp.append(value.range_start) + list_temp.append(value.range_stop) + list_temp.append(value.color) + list_ret.append(list_temp) + return list_ret + + @api.multi + @api.constrains('range_start', 'range_stop') + def check_range(self): + if self.range_start > self.range_stop: + raise exceptions.ValidationError("Start range should be less than stop range") diff --git a/project_lifeline/models/task_lifeline.py b/project_lifeline/models/task_lifeline.py new file mode 100644 index 000000000..6d1b57720 --- /dev/null +++ b/project_lifeline/models/task_lifeline.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2009-TODAY Cybrosys Technologies(). +# Author: Nilmar Shereef() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo import fields, models +from dateutil.relativedelta import relativedelta + + +class TaskLifeline(models.Model): + _inherit = 'project.task' + + lifeline = fields.Float(string="Life line", default='100', copy=False, readonly=True) + date_deadline = fields.Datetime('Deadline', required=True) + + def process_lifeline_scheduler(self): + task_obj = self.env['project.task'] + task_ids = task_obj.search([]) + time_now = fields.Datetime.from_string(fields.Datetime.now()) + for task in task_ids: + start_date = fields.Datetime.from_string(task.date_assign) + end_date = fields.Datetime.from_string(task.date_deadline) + if task.stage_id and (task.stage_id.name == 'Done' or task.stage_id.name == 'Cancelled'): + task.lifeline = 0 + else: + if task.date_deadline and task.date_assign and end_date > start_date: + if time_now < end_date: + total_difference_days = relativedelta(end_date, start_date) + difference_minute = total_difference_days.hours * 60 + total_difference_days.minutes + date_difference = end_date - start_date + total_difference_minute = int(date_difference.days) * 24 * 60 + difference_minute + + remaining_days = relativedelta(time_now, start_date) + remaining_minute = remaining_days.hours * 60 + remaining_days.minutes + date_remaining = time_now - start_date + total_minute_remaining = int(date_remaining.days) * 24 * 60 + remaining_minute + if total_difference_minute != 0: + task.lifeline = (100 - ((total_minute_remaining * 100) / total_difference_minute)) + else: + task.lifeline = 0 + else: + task.lifeline = 0 diff --git a/project_lifeline/static/description/banner.jpg b/project_lifeline/static/description/banner.jpg new file mode 100644 index 000000000..d1cec5ad4 Binary files /dev/null and b/project_lifeline/static/description/banner.jpg differ diff --git a/project_lifeline/static/description/cybro_logo.png b/project_lifeline/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/project_lifeline/static/description/cybro_logo.png differ diff --git a/project_lifeline/static/description/disply.png b/project_lifeline/static/description/disply.png new file mode 100644 index 000000000..31bf85a73 Binary files /dev/null and b/project_lifeline/static/description/disply.png differ diff --git a/project_lifeline/static/description/form_view.png b/project_lifeline/static/description/form_view.png new file mode 100644 index 000000000..481d02865 Binary files /dev/null and b/project_lifeline/static/description/form_view.png differ diff --git a/project_lifeline/static/description/icon.png b/project_lifeline/static/description/icon.png new file mode 100644 index 000000000..31bf85a73 Binary files /dev/null and b/project_lifeline/static/description/icon.png differ diff --git a/project_lifeline/static/description/index.html b/project_lifeline/static/description/index.html new file mode 100644 index 000000000..3da16973a --- /dev/null +++ b/project_lifeline/static/description/index.html @@ -0,0 +1,131 @@ +
+
+

LifeLine ProgressBar for Task

+

LifeLine is calculated based on live time and deadline time.

+

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+
+
+ ☀ User Defined Progress Bar Colour Configuration.
+ ☀ Task Lifeline Bar based on Deadline.
+ ☀ Automatic Colour Change of Lifeline Bar.
+ ☀ Default Colour for Forbidden.
+
+
+
+ +
+
+
+ +
+ +
+
+

+ ☛ Default Form/Tree view of Task +

+
+
+

Form View

+ +
+
+
+
+

Tree View

+ +
+
+
+
+ +
+
+

+ ☛User Can Define the Color of Progressbar for Different Percentage Ranges. +

+
+
+

Form View

+ +
+
+
+
+

Tree View

+ +
+
+
+
+
+
+
+
+

+ ☛Color of progressbar based on different ranges +

+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+

+ ☛Color of progressbar based on different ranges +

+
+
+ +
+
+
+
+ +
+
+
+
+
+
+

+ ☛Color of progressbar based on different ranges +

+
+
+ +
+
+
+
+ +
+
+
+
+ +
+

Need Any Help?

+ + +
\ No newline at end of file diff --git a/project_lifeline/static/description/set_green.png b/project_lifeline/static/description/set_green.png new file mode 100644 index 000000000..73bf0b6b6 Binary files /dev/null and b/project_lifeline/static/description/set_green.png differ diff --git a/project_lifeline/static/description/set_range_form_view.png b/project_lifeline/static/description/set_range_form_view.png new file mode 100644 index 000000000..3d30e7d91 Binary files /dev/null and b/project_lifeline/static/description/set_range_form_view.png differ diff --git a/project_lifeline/static/description/set_range_green.png b/project_lifeline/static/description/set_range_green.png new file mode 100644 index 000000000..1e7276fda Binary files /dev/null and b/project_lifeline/static/description/set_range_green.png differ diff --git a/project_lifeline/static/description/set_range_red.png b/project_lifeline/static/description/set_range_red.png new file mode 100644 index 000000000..7bd43950c Binary files /dev/null and b/project_lifeline/static/description/set_range_red.png differ diff --git a/project_lifeline/static/description/set_range_tree_view.png b/project_lifeline/static/description/set_range_tree_view.png new file mode 100644 index 000000000..56584cdea Binary files /dev/null and b/project_lifeline/static/description/set_range_tree_view.png differ diff --git a/project_lifeline/static/description/set_range_yellow.png b/project_lifeline/static/description/set_range_yellow.png new file mode 100644 index 000000000..6eed37af2 Binary files /dev/null and b/project_lifeline/static/description/set_range_yellow.png differ diff --git a/project_lifeline/static/description/set_red.png b/project_lifeline/static/description/set_red.png new file mode 100644 index 000000000..44ec54333 Binary files /dev/null and b/project_lifeline/static/description/set_red.png differ diff --git a/project_lifeline/static/description/set_yellow.png b/project_lifeline/static/description/set_yellow.png new file mode 100644 index 000000000..a0c92b762 Binary files /dev/null and b/project_lifeline/static/description/set_yellow.png differ diff --git a/project_lifeline/static/description/tree_view.png b/project_lifeline/static/description/tree_view.png new file mode 100644 index 000000000..e129503eb Binary files /dev/null and b/project_lifeline/static/description/tree_view.png differ diff --git a/project_lifeline/static/src/css/progress_bar_color.css b/project_lifeline/static/src/css/progress_bar_color.css new file mode 100644 index 000000000..e84014fae --- /dev/null +++ b/project_lifeline/static/src/css/progress_bar_color.css @@ -0,0 +1,52 @@ +.o_progressbar .o_progress .o_progressbar_complete.o_progress_gt_fty { + background-color: #456325; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_lt_fty { + background-color: orange; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_red { + background-color: #FF0000; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_pink { + background-color: #FFC0CB; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_orange { + background-color: #FFA500; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_yellow { + background-color: #FFFF00; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_light_green { + background-color: #00FF00; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_green { + background-color: #008000; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_grey { + background-color:#A9A9A9; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_blue { + background-color:#0000FF; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_purple { + background-color:#800080; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_brown { + background-color:#835C3B; + height: 100%; +} +.o_progressbar .o_progress .o_progressbar_complete.o_progress_black { + background-color:#000000; + height: 100%; +} \ No newline at end of file diff --git a/project_lifeline/static/src/js/progress_bar_color.js b/project_lifeline/static/src/js/progress_bar_color.js new file mode 100644 index 000000000..155cad3c0 --- /dev/null +++ b/project_lifeline/static/src/js/progress_bar_color.js @@ -0,0 +1,83 @@ +odoo.define('progress_bar_color.ProgressBar', function (require) { +"use strict"; + +var core = require('web.core'); +var utils = require('web.utils'); +var Widget = require('web.Widget'); +var ProgressBar = require('web.ProgressBar') +var Model = require('web.DataModel'); + +var QWeb = core.qweb; +var _t = core._t; + + +ProgressBar.include({ + + _render_value: function(v) { + var self = this + var value = this.value; + var max_value = this.max_value; + if(!isNaN(v)) { + if(this.edit_max_value) { + max_value = v; + } else { + value = v; + } + } + value = value || 0; + max_value = max_value || 0; + + var widthComplete; + if(value <= max_value) { + widthComplete = value/max_value * 100; + } else { + widthComplete = max_value/value * 100; + } + var Users = new Model('set.progressbar.color'); + Users.call('assign_progress_bar_color', [[]]).then(function (result) { + if (result[0]){ + for (var ranges = 0; ranges < result.length; ranges++){ + self.$('.o_progress').toggleClass('o_progress_overflow', value > max_value); + if (widthComplete >= result[ranges][0] && widthComplete <= result[ranges][1]){ + console.log(widthComplete) + self.$('.o_progressbar_complete').toggleClass('o_progress_red', result[ranges][2] == 'red').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_pink', result[ranges][2] == 'pink').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_orange', result[ranges][2] == 'orange').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_yellow', result[ranges][2] == 'yellow').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_light_green', result[ranges][2] == 'light_green').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_green', result[ranges][2] == 'green').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_grey', result[ranges][2] == 'grey').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_blue', result[ranges][2] == 'blue').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_purple', result[ranges][2] == 'purple').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_black', result[ranges][2] == 'black').css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_brown', result[ranges][2] == 'brown').css('width', widthComplete + '%'); + + break; + } + else if (ranges == (result.length - 1)){ + self.$('.o_progressbar_complete').toggleClass('o_progress_grey', widthComplete != 0).css('width', widthComplete + '%'); + } + + } + } + else{ + self.$('.o_progress').toggleClass('o_progress_overflow', value > max_value); + self.$('.o_progressbar_complete').toggleClass('o_progress_gt_fty', widthComplete > 50).css('width', widthComplete + '%'); + self.$('.o_progressbar_complete').toggleClass('o_progress_lt_fty', widthComplete <= 50).css('width', widthComplete + '%'); + } + }); + + if(this.readonly) { + if(max_value !== 100) { + this.$('.o_progressbar_value').html(utils.human_number(value) + " / " + utils.human_number(max_value)); + } else { + this.$('.o_progressbar_value').html(utils.human_number(value) + "%"); + } + } else if(isNaN(v)) { + this.$('.o_progressbar_value').val(this.edit_max_value ? max_value : value); + } + } +}); + + +}); diff --git a/project_lifeline/views/progress_bar_settings.xml b/project_lifeline/views/progress_bar_settings.xml new file mode 100644 index 000000000..d74702d31 --- /dev/null +++ b/project_lifeline/views/progress_bar_settings.xml @@ -0,0 +1,54 @@ + + + + + + set.progressbar.color.tree + set.progressbar.color + + + + + + + + + + + set.progressbar.color.form + set.progressbar.color + +
+ + + + + + + + + + + +
+
+
+ + + Set Range + set.progressbar.color + form + tree,form + +

+ Create a new range +

+ Create a new range and assign a color for progress bar +

+
+
+ + +
+
\ No newline at end of file diff --git a/project_lifeline/views/progress_bar_view.xml b/project_lifeline/views/progress_bar_view.xml new file mode 100644 index 000000000..3937901eb --- /dev/null +++ b/project_lifeline/views/progress_bar_view.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/project_lifeline/views/task_lifeline_view.xml b/project_lifeline/views/task_lifeline_view.xml new file mode 100644 index 000000000..913ca995f --- /dev/null +++ b/project_lifeline/views/task_lifeline_view.xml @@ -0,0 +1,39 @@ + + + + Lifeline scheduler + + 1 + minutes + -1 + + + + + + + project.lifeline.tree + project.task + + + + + + + + + + project.lifeline.form + project.task + + + + + + + + + + + + \ No newline at end of file