diff --git a/restricted_task_following/README.rst b/restricted_task_following/README.rst new file mode 100644 index 000000000..333fb79c8 --- /dev/null +++ b/restricted_task_following/README.rst @@ -0,0 +1,28 @@ +============================ +Restricted Task Following v9 +============================ + +This module allow Only assigned & created person will follow the task, Restrict other followers of project. + +Installation +============ + +Just select it from available modules to install it, there is no need to extra installations. + +Configuration +============= + +* Tick 'Disable Automatic Task Following' boolean field from project master to enable this feature. + +Features +======== + +* Option to Disable Automatic Task Following From Project Followers. +* User Can Add Custom Followers to Task. + +Credits +======= +Developer: Aswani pc @ cybrosys +Guidance: Nilmar Shereef @ cybrosys, shereef@cybrosys.in + + diff --git a/restricted_task_following/__init__.py b/restricted_task_following/__init__.py new file mode 100644 index 000000000..989dc9bb2 --- /dev/null +++ b/restricted_task_following/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-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 . import models diff --git a/restricted_task_following/__openerp__.py b/restricted_task_following/__openerp__.py new file mode 100644 index 000000000..e02718478 --- /dev/null +++ b/restricted_task_following/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-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': "Disable Auto Task Following", + 'version': '10.0.1.0', + 'summary': """Only assignee & assigned person will follow the task, Restrict other followers of project""", + 'category': 'Project', + 'description': """This module adds an option to remove automatic followers of project on task""", + 'author': "Cybrosys Techno Solutions", + 'company': "Cybrosys Techno Solutions", + 'website': "http://www.cybrosys.com", + 'depends': ['base', 'project'], + 'data': ['views/restrict_task_following.xml'], + + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'license': 'LGPL-3', + 'auto_install': False, +} diff --git a/restricted_task_following/models/__init__.py b/restricted_task_following/models/__init__.py new file mode 100644 index 000000000..9b70a9a6d --- /dev/null +++ b/restricted_task_following/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-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 . import restrict_task_following diff --git a/restricted_task_following/models/restrict_task_following.py b/restricted_task_following/models/restrict_task_following.py new file mode 100644 index 000000000..d608b8db0 --- /dev/null +++ b/restricted_task_following/models/restrict_task_following.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-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 openerp import models, fields, api + + +class TaskFollow(models.Model): + _inherit = 'project.task' + + @api.multi + def message_auto_subscribe(self, updated_fields, values=None): + + """ override 'message_auto_subscribe' function in 'mail.thread' .""" + + new_partners, new_channels = dict(), dict() + restrict_task_follow = self.project_id.restrict_automatic_task_follow + user_field_lst = self._message_get_auto_subscribe_fields(updated_fields) + subtypes = self.env['mail.message.subtype'].search( + ['|', ('res_model', '=', False), ('parent_id.res_model', '=', self._name)]) + relation_fields = set([subtype.relation_field for subtype in subtypes if subtype.relation_field is not False]) + if not any(relation in updated_fields for relation in relation_fields) and not user_field_lst: + return True + if values is None: + record = self[0] + for updated_field in updated_fields: + field_value = getattr(record, updated_field) + if isinstance(field_value, models.BaseModel): + field_value = field_value.id + values[updated_field] = field_value + headers = set() + for subtype in subtypes: + if subtype.relation_field and values.get(subtype.relation_field): + headers.add((subtype.res_model, values.get(subtype.relation_field))) + if headers: + header_domain = ['|'] * (len(headers) - 1) + for header in headers: + header_domain += ['&', ('res_model', '=', header[0]), ('res_id', '=', header[1])] + if not restrict_task_follow: + for header_follower in self.env['mail.followers'].sudo().search(header_domain): + for subtype in header_follower.subtype_ids: + if subtype.parent_id and subtype.parent_id.res_model == self._name: + new_subtype = subtype.parent_id + elif subtype.res_model is False: + new_subtype = subtype + else: + continue + if header_follower.partner_id: + new_partners.setdefault(header_follower.partner_id.id, set()).add(new_subtype.id) + else: + new_channels.setdefault(header_follower.channel_id.id, set()).add(new_subtype.id) + user_ids = [values[name] for name in user_field_lst if values.get(name)] + user_pids = [user.partner_id.id for user in self.env['res.users'].sudo().browse(user_ids)] + for partner_id in user_pids: + new_partners.setdefault(partner_id, None) + for pid, subtypes in new_partners.items(): + subtypes = list(subtypes) if subtypes is not None else None + self.message_subscribe(partner_ids=[pid], subtype_ids=subtypes, force=(subtypes != None)) + for cid, subtypes in new_channels.items(): + subtypes = list(subtypes) if subtypes is not None else None + self.message_subscribe(channel_ids=[cid], subtype_ids=subtypes, force=(subtypes != None)) + user_pids = [user_pid for user_pid in user_pids if user_pid != self.env.user.partner_id.id] + self._message_auto_subscribe_notify(user_pids) + return True + + +class ProjectFollow(models.Model): + _inherit = 'project.project' + + restrict_automatic_task_follow = fields.Boolean(string="Disable Automatic Task Following", + help="It will remove unwanted project followers on task." + "Only assigned person & created person will follow " + "this task automatically.") diff --git a/restricted_task_following/static/description/banner.jpg b/restricted_task_following/static/description/banner.jpg new file mode 100644 index 000000000..f548b8b56 Binary files /dev/null and b/restricted_task_following/static/description/banner.jpg differ diff --git a/restricted_task_following/static/description/cybro_logo.png b/restricted_task_following/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/restricted_task_following/static/description/cybro_logo.png differ diff --git a/restricted_task_following/static/description/icon.png b/restricted_task_following/static/description/icon.png new file mode 100644 index 000000000..eb5edcfbe Binary files /dev/null and b/restricted_task_following/static/description/icon.png differ diff --git a/restricted_task_following/static/description/index.html b/restricted_task_following/static/description/index.html new file mode 100644 index 000000000..af14b1f43 --- /dev/null +++ b/restricted_task_following/static/description/index.html @@ -0,0 +1,60 @@ +
+
+

Disable Auto Task Following

+

Only assigned & created person will follow the task, Restrict other followers of project

+ +

Author : Cybrosys Techno Solutions , www.cybrosys.com

+

Features:

+
    +
  •    Option to Disable Automatic Task Following From Project Followers
  • +
  •    User Can Add Custom Followers to Task
  • +
+
+
+ +
+
+

Option Disable Automatic Task Following

+
+ +
+
+
+ +
+
+

Only assignee & Assigned Person will Follow the Task By Default

+
+ +
+
+
+ +
+

Need Any Help?

+ +
+ + + diff --git a/restricted_task_following/static/description/pro_form.png b/restricted_task_following/static/description/pro_form.png new file mode 100644 index 000000000..40b49f01d Binary files /dev/null and b/restricted_task_following/static/description/pro_form.png differ diff --git a/restricted_task_following/static/description/task_form.png b/restricted_task_following/static/description/task_form.png new file mode 100644 index 000000000..9b806ca32 Binary files /dev/null and b/restricted_task_following/static/description/task_form.png differ diff --git a/restricted_task_following/views/restrict_task_following.xml b/restricted_task_following/views/restrict_task_following.xml new file mode 100644 index 000000000..71920a9fd --- /dev/null +++ b/restricted_task_following/views/restrict_task_following.xml @@ -0,0 +1,15 @@ + + + + + project.project.form + project.project + + + + + + + + + \ No newline at end of file