Skip to content
Permalink
Browse files

⚡️ project_task_subtask added group "Allow edit others tasks"

  • Loading branch information...
Ommo73 committed Apr 22, 2019
1 parent 4afb31e commit 681280afa8227a6871cb3f518de8a4187a2641d6
@@ -21,6 +21,8 @@ Features:
* default filter: "My", "TODO"
* optional group by: "Project", "Task", "User", "State"

* Added group "Allow edit others tasks"

Credits
=======

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import models

@@ -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",

@@ -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">
@@ -3,6 +3,7 @@
-------

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

`1.0.0`
-------
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# License LGPL-3.0 (https://www.gnu.org/licenses/lgpl.html).
from . import project_task_subtask

@@ -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
@@ -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
@@ -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
@@ -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:
@@ -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

@@ -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>
@@ -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">
@@ -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"/>
@@ -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"/>

0 comments on commit 681280a

Please sign in to comment.
You can’t perform that action at this time.