diff --git a/project_task_timer/README.rst b/project_task_timer/README.rst new file mode 100644 index 000000000..3f4bab899 --- /dev/null +++ b/project_task_timer/README.rst @@ -0,0 +1,19 @@ +Project Task Timer v12 +====================================== +Task Timer with Start & Stop + +Installation +============ + - www.odoo.com/documentation/12.0/setup/install.html + - Install our custom addon + +Configuration +============= + + No additional configurations needed + +Credits +======= + Developer: Jesni Banu v10 @ cybrosys, Contact: odoo@cybrosys.com + Kavya Raveendran v11 @ cybrosys, Contact: odoo@cybrosys.com + Kavya Raveendran v12 @ cybrosys, Contact: odoo@cybrosys.com diff --git a/project_task_timer/__init__.py b/project_task_timer/__init__.py new file mode 100644 index 000000000..664b6ea1d --- /dev/null +++ b/project_task_timer/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# 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 . import models diff --git a/project_task_timer/__manifest__.py b/project_task_timer/__manifest__.py new file mode 100644 index 000000000..99ad09e3a --- /dev/null +++ b/project_task_timer/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# 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': 'Project Task Timer', + 'version': '12.0.1.0', + 'summary': """Task Timer With Start & Stop""", + 'description': """"This module helps you to track time sheet in project automatically.""", + 'category': 'Project', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "http://www.cybrosys.com", + 'depends': ['base', 'project', 'hr_timesheet'], + 'data': [ + 'views/project_task_timer_view.xml', + 'views/project_timer_static.xml', + ], + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'demo': [], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/project_task_timer/doc/RELEASE_NOTES.md b/project_task_timer/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..8e8069b89 --- /dev/null +++ b/project_task_timer/doc/RELEASE_NOTES.md @@ -0,0 +1,4 @@ +## Module + +#### 18.04.2019 +#### Version 12.0.1.0.0 diff --git a/project_task_timer/models/__init__.py b/project_task_timer/models/__init__.py new file mode 100644 index 000000000..7b117f489 --- /dev/null +++ b/project_task_timer/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# 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 . import project_task_timer diff --git a/project_task_timer/models/project_task_timer.py b/project_task_timer/models/project_task_timer.py new file mode 100644 index 000000000..75a3f6354 --- /dev/null +++ b/project_task_timer/models/project_task_timer.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Jesni Banu() +# 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 datetime import datetime +from odoo import models, fields, api + + +class ProjectTaskTimeSheet(models.Model): + _inherit = 'account.analytic.line' + + date_start = fields.Datetime(string='Start Date') + date_end = fields.Datetime(string='End Date', readonly=1) + timer_duration = fields.Float(invisible=1, string='Time Duration (Minutes)') + + +class ProjectTaskTimer(models.Model): + _inherit = 'project.task' + + task_timer = fields.Boolean() + is_user_working = fields.Boolean( + 'Is Current User Working', compute='_compute_is_user_working', + help="Technical field indicating whether the current user is working. ") + duration = fields.Float( + 'Real Duration', compute='_compute_duration', + store=True) + + def _compute_is_user_working(self): + """ Checks whether the current user is working """ + for order in self: + if order.timesheet_ids.filtered(lambda x: (x.user_id.id == self.env.user.id) and (not x.date_end)): + order.is_user_working = True + else: + order.is_user_working = False + + @api.multi + def toggle_start(self): + for record in self: + record.task_timer = not record.task_timer + if self.task_timer: + self.write({'is_user_working': True}) + time_line = self.env['account.analytic.line'] + for time_sheet in self: + time_line.create({ + 'name': self.env.user.name + ': ' + time_sheet.name, + 'task_id': time_sheet.id, + 'user_id': self.env.user.id, + 'project_id': time_sheet.project_id.id, + 'date_start': datetime.now(), + }) + else: + self.write({'is_user_working': False}) + time_line_obj = self.env['account.analytic.line'] + domain = [('task_id', 'in', self.ids), ('date_end', '=', False)] + for time_line in time_line_obj.search(domain): + time_line.write({'date_end': fields.Datetime.now()}) + if time_line.date_end: + diff = fields.Datetime.from_string(time_line.date_end) - fields.Datetime.from_string( + time_line.date_start) + time_line.timer_duration = round(diff.total_seconds() / 60.0, 2) + time_line.unit_amount = round(diff.total_seconds() / (60.0 * 60.0), 2) + else: + time_line.unit_amount = 0.0 + time_line.timer_duration = 0.0 + + + + diff --git a/project_task_timer/static/description/banner.jpg b/project_task_timer/static/description/banner.jpg new file mode 100644 index 000000000..1ce48898d Binary files /dev/null and b/project_task_timer/static/description/banner.jpg differ diff --git a/project_task_timer/static/description/cybro_logo.png b/project_task_timer/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/project_task_timer/static/description/cybro_logo.png differ diff --git a/project_task_timer/static/description/icon.png b/project_task_timer/static/description/icon.png new file mode 100644 index 000000000..df58193f0 Binary files /dev/null and b/project_task_timer/static/description/icon.png differ diff --git a/project_task_timer/static/description/index.html b/project_task_timer/static/description/index.html new file mode 100644 index 000000000..fb6ae5eed --- /dev/null +++ b/project_task_timer/static/description/index.html @@ -0,0 +1,363 @@ +
+
+

+ Project Task Timer +

+

+ Task Timer with Start & Stop +

+
+ Cybrosys Technologies +
+ +
+ cybrosys technologies
+
+
+
+ +
+ +
+

+ Overview +

+

+ You have a smart button to start & stop your task. When you start your task, + it will automatically process a time sheet entry for that particular task with starting time. When you toggle + it to pause, the task end date will be updated and the duration gets automatically calculated. +

+
+ + +
+

+ Configuration +

+

+ No additional configuration required +

+
+ +
+ +
+ +
+

+ Features +

+

+ + Timer in Task. +

+

+ + Automatic Time sheet Calculation. +

+
+ +
+ +
+ +
+

+ Screenshots +

+ +

+ + Project -> Search -> Task +

+
+ +
+ + +

+ + Here we can view the start date and end date. +

+
+ +
+ + +

+ + Automatic Time sheet Calculation.
+Here you can see the automated time sheet entries. +

+
+ +
+
+
+ +
+
+ cybrosys technologies +
+
+ +
+
+

+ Our Services +

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

+ + Odoo Support +

+ +
+ +
+
+
+
+
+

+ Our Industries +

+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Trading + +

+

+ Easily procure and sell your products. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Manufacturing +

+

+ Plan, track and schedule your operations. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Restaurant +

+

+ Run your bar or restaurant methodical. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + POS +

+

+ Easy configuring and convivial selling. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + E-commerce & Website +

+

+ Mobile friendly, awe-inspiring product pages. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Hotel Management +

+

+ An all-inclusive hotel management application. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Education +

+

+ A Collaborative platform for educational management. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Service Management +

+

+ Keep track of services and invoice accordingly. +

+
+
+
+
+
+
+ +
diff --git a/project_task_timer/static/description/project-task-timer-cybrosys-1.jpg b/project_task_timer/static/description/project-task-timer-cybrosys-1.jpg new file mode 100644 index 000000000..f7b118a6a Binary files /dev/null and b/project_task_timer/static/description/project-task-timer-cybrosys-1.jpg differ diff --git a/project_task_timer/static/description/project-task-timer-cybrosys-2.jpg b/project_task_timer/static/description/project-task-timer-cybrosys-2.jpg new file mode 100644 index 000000000..834eea20e Binary files /dev/null and b/project_task_timer/static/description/project-task-timer-cybrosys-2.jpg differ diff --git a/project_task_timer/static/description/project-task-timer-cybrosys-3.jpg b/project_task_timer/static/description/project-task-timer-cybrosys-3.jpg new file mode 100644 index 000000000..36b77785a Binary files /dev/null and b/project_task_timer/static/description/project-task-timer-cybrosys-3.jpg differ diff --git a/project_task_timer/static/src/js/timer.js b/project_task_timer/static/src/js/timer.js new file mode 100644 index 000000000..8412cca3d --- /dev/null +++ b/project_task_timer/static/src/js/timer.js @@ -0,0 +1,63 @@ +odoo.define('project_task_timer.timer', function (require) { +"use strict"; +var AbstractField = require('web.AbstractField'); +var core = require('web.core'); +var field_registry = require('web.field_registry'); +var time = require('web.time'); +var FieldManagerMixin = require('web.FieldManagerMixin'); + +var _t = core._t; + +var TimeCounter = AbstractField.extend({ + + willStart: function () { + var self = this; + var def = this._rpc({ + model: 'account.analytic.line', + method: 'search_read', + domain: [['task_id', '=', this.res_id], ['user_id', '=', self.record.context['uid']]], + }).then(function (result) { + if (self.mode === 'readonly') { + var currentDate = new Date(); + self.duration = 0; + _.each(result, function (data) { + self.duration += data.date_end ? + self._getDateDifference(data.date_start, data.date_end) : + self._getDateDifference(time.auto_str_to_date(data.date_start), currentDate); + }); + } + }); + return $.when(this._super.apply(this, arguments), def); + }, + destroy: function () { + this._super.apply(this, arguments); + clearTimeout(this.timer); + }, + isSet: function () { + return true; + }, + _getDateDifference: function (dateStart, dateEnd) { + return moment(dateEnd).diff(moment(dateStart)); + }, + + _render: function () { + this._startTimeCounter(); + }, + _startTimeCounter: function () { + var self = this; + clearTimeout(this.timer); + if (this.record.data.is_user_working) { + this.timer = setTimeout(function () { + self.duration += 1000; + self._startTimeCounter(); + }, 1000); + } else { + clearTimeout(this.timer); + } + this.$el.html($('' + moment.utc(this.duration).format("HH:mm:ss") + '')); + }, +}); +field_registry.add('timesheet_uoms', TimeCounter); +}); + + diff --git a/project_task_timer/views/project_task_timer_view.xml b/project_task_timer/views/project_task_timer_view.xml new file mode 100644 index 000000000..47f35722b --- /dev/null +++ b/project_task_timer/views/project_task_timer_view.xml @@ -0,0 +1,45 @@ + + + + + project task timer + project.task + + + + + + + + + project task timer1 + project.task + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project_task_timer/views/project_timer_static.xml b/project_task_timer/views/project_timer_static.xml new file mode 100644 index 000000000..6c3566376 --- /dev/null +++ b/project_task_timer/views/project_timer_static.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file