Skip to content

Commit

Permalink
⚡ project_task_subtask added group "Allow edit others tasks"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ommo73 committed May 8, 2019
1 parent 4afb31e commit 681280a
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 20 deletions.
2 changes: 2 additions & 0 deletions project_task_subtask/README.rst
Expand Up @@ -21,6 +21,8 @@ Features:
* default filter: "My", "TODO"
* optional group by: "Project", "Task", "User", "State"

* Added group "Allow edit others tasks"

Credits
=======

Expand Down
1 change: 1 addition & 0 deletions project_task_subtask/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models

7 changes: 5 additions & 2 deletions project_task_subtask/__openerp__.py
@@ -1,16 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Project Task To-Do List""",
"summary": """Use To-Do List to be ensure that all your tasks are performed and to make easy control over them""",
"category": """Project Management""",
"images": ['images/todolist_main.png'],
"version": "1.0.0",
"version": "8.0.1.1.0",
"application": False,

"author": "IT-Projects LLC, Manaev Rafael",
"support": "apps@it-projects.info",
"website": "https://it-projects.info",
"license": "GPL-3",
"license": "LGPL-3",
"price": 69.00,
"currency": "EUR",

Expand Down
5 changes: 4 additions & 1 deletion project_task_subtask/data/subscription_template.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2017 manawi <https://github.com/manawi>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). -->
<openerp>
<data>
<record id="subtasks_subtype" model="mail.message.subtype">
Expand Down
1 change: 1 addition & 0 deletions project_task_subtask/doc/changelog.rst
Expand Up @@ -3,6 +3,7 @@
-------

- **Improvement**: 'Checklist' replaced by 'To-Do List'
- **New**: added group "Allow edit others tasks"

`1.0.0`
-------
Expand Down
1 change: 1 addition & 0 deletions project_task_subtask/models/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import project_task_subtask

37 changes: 25 additions & 12 deletions project_task_subtask/models/project_task_subtask.py
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-

# Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
# Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2017 manawi <https://github.com/manawi>
# Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from openerp import models, fields, api
from openerp.tools import html_escape as escape
from openerp.exceptions import Warning as UserError
Expand Down Expand Up @@ -34,8 +38,13 @@ def _compute_recolor(self):

@api.multi
def _compute_hide_button(self):
group = self.env.ref('project_task_subtask.project_subtask_rule')
for record in self:
if self.env.user not in [record.reviewer_id, record.user_id]:
if self.env.user in [record.reviewer_id, record.user_id]:
record.hide_button = False
elif group in self.env.user.groups_id:
record.hide_button = False
else:
record.hide_button = True

@api.multi
Expand All @@ -53,17 +62,17 @@ def _needaction_domain_get(self):
def write(self, vals):
old_names = dict(zip(self.mapped('id'), self.mapped('name')))
result = super(ProjectTaskSubtask, self).write(vals)
for r in self:
for subtask in self:
if vals.get('state'):
r.task_id.send_subtask_email(r.name, r.state, r.reviewer_id.id, r.user_id.id)
if self.env.user != r.reviewer_id and self.env.user != r.user_id:
raise UserError(_('Only users related to that subtask can change state.'))
subtask.task_id.send_subtask_email(subtask.name, subtask.state, subtask.reviewer_id.id, subtask.user_id.id)
if self.env.user != subtask.reviewer_id and self.env.user != subtask.user_id and self.env.user.partner_id not in subtask.task_id.message_follower_ids:
raise UserError(_('Only users related to that subtask or users with special rights can change state.'))
if vals.get('name'):
r.task_id.send_subtask_email(r.name, r.state, r.reviewer_id.id, r.user_id.id, old_name=old_names[r.id])
if self.env.user != r.reviewer_id and self.env.user != r.user_id:
raise UserError(_('Only users related to that subtask can change state.'))
subtask.task_id.send_subtask_email(subtask.name, subtask.state, subtask.reviewer_id.id, subtask.user_id.id, old_name=old_names[subtask.id])
if self.env.user != subtask.reviewer_id and self.env.user != subtask.user_id and self.env.user.partner_id not in subtask.task_id.message_follower_ids:
raise UserError(_('Only users related to that subtask or users with special rights can change state.'))
if vals.get('user_id'):
r.task_id.send_subtask_email(r.name, r.state, r.reviewer_id.id, r.user_id.id)
subtask.task_id.send_subtask_email(subtask.name, subtask.state, subtask.reviewer_id.id, subtask.user_id.id)
return result

@api.model
Expand Down Expand Up @@ -167,8 +176,12 @@ def send_subtask_email(self, subtask_name, subtask_state, subtask_reviewer_id, s
body = '<p>' + escape(reviewer.name) + ', <em style="color:#999">I updated To-Do List item assigned to me:</em> <br><strong>' + state + '</strong>: ' + escape(subtask_name)
partner_ids = [reviewer.partner_id.id]
else:
body = '<p>' + escape(user.name) + ', ' + escape(reviewer.name) + ', <em style="color:#999">I updated To-Do List item, now its assigned to ' + escape(user.name) + ': </em> <br><strong>' + state + '</strong>: ' + escape(subtask_name)
partner_ids = [user.partner_id.id, reviewer.partner_id.id]
if user.id == reviewer.id:
body = '<p>' + escape(reviewer.name) + ', <em style="color:#999">I updated Subtask assigned to ' + escape(user.name) + ': </em> <br><strong>' + state + '</strong>: ' + escape(subtask_name)
partner_ids = [user.partner_id.id]
else:
body = '<p>' + escape(reviewer.name) + escape(user.name) + ', <em style="color:#999">I updated Subtask assigned to ' + escape(user.name) + ': </em> <br><strong>' + state + '</strong>: ' + escape(subtask_name)
partner_ids = [user.partner_id.id, reviewer.partner_id.id]
if old_name:
body = body + '<br><em style="color:#999">Updated from</em><br><strong>' + state + '</strong>: ' + escape(old_name) + '</p>'
else:
Expand Down
1 change: 0 additions & 1 deletion project_task_subtask/security/ir.model.access.csv
@@ -1,3 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_task_subtask,project.task.subtask,model_project_task_subtask,project.group_project_user,1,1,1,0

12 changes: 10 additions & 2 deletions project_task_subtask/security/project_security.xml
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
Copyright 2019 Artem Rafailov <https://it-projects.info/team/Ommo73/>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). -->
<openerp>
<data>
<data noupdate="1">

<record id="project_subtask_rule" model="res.groups">
<field name="name">Allow edit others tasks</field>
<field name="category_id" ref="base.module_category_usability"/>
<field name="comment">The user will have access to edit others tasks.</field>
</record>

</data>
</openerp>
8 changes: 6 additions & 2 deletions project_task_subtask/views/project_task_subtask.xml
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
Copyright 2017 manawi <https://github.com/manawi>
License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html). -->
<openerp>
<data>
<record id="view_task_form2" model="ir.ui.view">
Expand All @@ -10,7 +14,7 @@
<page string="To-Do List">
<field name="default_user" invisible='True'/>
<field name="subtask_ids" context="{'default_user_id': default_user}">
<tree string="Task Work" editable="bottom" colors="red:recolor == True;gray:state == 'cancelled';green:state == 'done';#b818ce:state == 'waiting'">
<tree editable="bottom" colors="red:recolor == True;gray:state == 'cancelled';green:state == 'done';#b818ce:state == 'waiting'">
<field name="name"/>
<field name="recolor" invisible='True'/>
<field name="user_id"/>
Expand Down Expand Up @@ -86,7 +90,7 @@
<field name="name">subtask.list.form</field>
<field name="model">project.task.subtask</field>
<field name="arch" type="xml">
<tree string="subtask_list_form">
<tree>
<field name="name"/>
<field name="user_id"/>
<field name="reviewer_id"/>
Expand Down

0 comments on commit 681280a

Please sign in to comment.