From 76af9027a7c46e9037371bdf41ffe270c2281879 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 4 Apr 2013 10:48:24 +0200 Subject: [IMP] Add options for privacy_visibility in project bzr revid: jco@openerp.com-20130404084824-notnfhyda1w4q2ig --- addons/project/project.py | 39 ++++++++++++++++++++++++---- addons/project/security/project_security.xml | 14 +++++++--- 2 files changed, 44 insertions(+), 9 deletions(-) (limited to 'addons/project') diff --git a/addons/project/project.py b/addons/project/project.py index 0751865d9c4..e4d08d82f16 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -173,6 +173,35 @@ class project(osv.osv): res[id]['progress_rate'] = 0.0 return res + #We want to test this to check if it can avoid whether it has access + def _progress_rate2(self, cr, uid, ids, names, arg, context=None): + child_parent = self._get_project_and_children(cr, uid, ids, context) + tasks = self.pool.get("project.task").search(cr, uid, [('project_id', 'in', child_parent.keys()), ('state','!=','cancel')], context=context) + cr.execute(""" + SELECT project_id, COALESCE(SUM(planned_hours), 0.0), + COALESCE(SUM(total_hours), 0.0), COALESCE(SUM(effective_hours), 0.0) + FROM project_task WHERE id IN %s AND state <> 'cancelled' + GROUP BY project_id + """, (tuple(tasks),)) + # aggregate results into res + res = dict([(id, {'planned_hours':0.0,'total_hours':0.0,'effective_hours':0.0}) for id in ids]) + for id, planned, total, effective in cr.fetchall(): + # add the values specific to id to all parent projects of id in the result + while id: + if id in ids: + res[id]['planned_hours'] += planned + res[id]['total_hours'] += total + res[id]['effective_hours'] += effective + id = child_parent[id] + # compute progress rates + for id in ids: + if res[id]['total_hours']: + res[id]['progress_rate'] = round(100.0 * res[id]['effective_hours'] / res[id]['total_hours'], 2) + else: + res[id]['progress_rate'] = 0.0 + return res + + def unlink(self, cr, uid, ids, context=None): alias_ids = [] mail_alias = self.pool.get('mail.alias') @@ -238,22 +267,22 @@ class project(osv.osv): 'members': fields.many2many('res.users', 'project_user_rel', 'project_id', 'uid', 'Project Members', help="Project's members are users who can have an access to the tasks related to this project.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'tasks': fields.one2many('project.task', 'project_id', "Task Activities"), - 'planned_hours': fields.function(_progress_rate, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.", + 'planned_hours': fields.function(_progress_rate2, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'effective_hours': fields.function(_progress_rate, multi="progress", string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.", + 'effective_hours': fields.function(_progress_rate2, multi="progress", string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'total_hours': fields.function(_progress_rate, multi="progress", string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.", + 'total_hours': fields.function(_progress_rate2, multi="progress", string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'progress_rate': fields.function(_progress_rate, multi="progress", string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.", + 'progress_rate': fields.function(_progress_rate2, multi="progress", string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), @@ -267,7 +296,7 @@ class project(osv.osv): "with Tasks (or optionally Issues if the Issue Tracker module is installed)."), 'alias_model': fields.selection(_alias_models, "Alias Model", select=True, required=True, help="The kind of document created when an email is received on this project's email alias"), - 'privacy_visibility': fields.selection([('public','All Users'), ('followers','Followers Only')], 'Privacy / Visibility', required=True), + 'privacy_visibility': fields.selection([('publicall', 'All Users All Tasks'), ('employees','All Employees'), ('public','All Users'), ('followers','Followers Only')], 'Privacy / Visibility', required=True), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') } diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index f1d8c7e760f..59ad1a9b0fa 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -48,24 +48,30 @@ Public Members - ['|',('privacy_visibility','in',[False,'public']),('message_follower_ids','in',[user.partner_id.id])] + ['|',('privacy_visibility','in',['public', 'publicall', 'employees']),('message_follower_ids','in',[user.partner_id.id])] + Task multi-company - ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] Tasks According to User and Project - - ['|','|','|',('user_id','=',False),('user_id','=',user.id),('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)] + ['|','|','|','|',('project_id.visibility', '=', 'publicall'),('user_id','=',False),('user_id','=',user.id),('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)] + + Project Managers: all tasks from all projects -- cgit v1.2.3 From ecbcbdfbb6f830df3896a1b9dc194c1f404c845a Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 4 Apr 2013 12:04:57 +0200 Subject: [FIX] Progress rate visibility not an issue in trunk bzr revid: jco@openerp.com-20130404100457-5jm3e37ilatoto2n --- addons/project/project.py | 38 +++++--------------------------------- addons/project/project_view.xml | 2 +- 2 files changed, 6 insertions(+), 34 deletions(-) (limited to 'addons/project') diff --git a/addons/project/project.py b/addons/project/project.py index e4d08d82f16..998060d652c 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -173,34 +173,6 @@ class project(osv.osv): res[id]['progress_rate'] = 0.0 return res - #We want to test this to check if it can avoid whether it has access - def _progress_rate2(self, cr, uid, ids, names, arg, context=None): - child_parent = self._get_project_and_children(cr, uid, ids, context) - tasks = self.pool.get("project.task").search(cr, uid, [('project_id', 'in', child_parent.keys()), ('state','!=','cancel')], context=context) - cr.execute(""" - SELECT project_id, COALESCE(SUM(planned_hours), 0.0), - COALESCE(SUM(total_hours), 0.0), COALESCE(SUM(effective_hours), 0.0) - FROM project_task WHERE id IN %s AND state <> 'cancelled' - GROUP BY project_id - """, (tuple(tasks),)) - # aggregate results into res - res = dict([(id, {'planned_hours':0.0,'total_hours':0.0,'effective_hours':0.0}) for id in ids]) - for id, planned, total, effective in cr.fetchall(): - # add the values specific to id to all parent projects of id in the result - while id: - if id in ids: - res[id]['planned_hours'] += planned - res[id]['total_hours'] += total - res[id]['effective_hours'] += effective - id = child_parent[id] - # compute progress rates - for id in ids: - if res[id]['total_hours']: - res[id]['progress_rate'] = round(100.0 * res[id]['effective_hours'] / res[id]['total_hours'], 2) - else: - res[id]['progress_rate'] = 0.0 - return res - def unlink(self, cr, uid, ids, context=None): alias_ids = [] @@ -267,22 +239,22 @@ class project(osv.osv): 'members': fields.many2many('res.users', 'project_user_rel', 'project_id', 'uid', 'Project Members', help="Project's members are users who can have an access to the tasks related to this project.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'tasks': fields.one2many('project.task', 'project_id', "Task Activities"), - 'planned_hours': fields.function(_progress_rate2, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.", + 'planned_hours': fields.function(_progress_rate, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'effective_hours': fields.function(_progress_rate2, multi="progress", string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.", + 'effective_hours': fields.function(_progress_rate, multi="progress", string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'total_hours': fields.function(_progress_rate2, multi="progress", string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.", + 'total_hours': fields.function(_progress_rate, multi="progress", string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), }), - 'progress_rate': fields.function(_progress_rate2, multi="progress", string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.", + 'progress_rate': fields.function(_progress_rate, multi="progress", string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.", store = { 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'work_ids', 'state'], 20), @@ -296,7 +268,7 @@ class project(osv.osv): "with Tasks (or optionally Issues if the Issue Tracker module is installed)."), 'alias_model': fields.selection(_alias_models, "Alias Model", select=True, required=True, help="The kind of document created when an email is received on this project's email alias"), - 'privacy_visibility': fields.selection([('publicall', 'All Users All Tasks'), ('employees','All Employees'), ('public','All Users'), ('followers','Followers Only')], 'Privacy / Visibility', required=True), + 'privacy_visibility': fields.selection([('publicall', 'All users will see all tasks'), ('public','All users'), ('employees','All employees'), ('followers','Followers Only')], 'Privacy / Visibility', required=True), 'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,), 'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int') } diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 16dbe44ccc1..dd51f9d6acf 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -99,7 +99,7 @@ - + -- cgit v1.2.3 From 6adfab181d9b4c91ccf7cd1677d1560a148009fc Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 4 Apr 2013 12:08:32 +0200 Subject: [FIX] Remove comments bzr revid: jco@openerp.com-20130404100832-u1bdhqmkqjcm87pk --- addons/project/security/project_security.xml | 7 ------- 1 file changed, 7 deletions(-) (limited to 'addons/project') diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index 59ad1a9b0fa..5374549d9ed 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -65,13 +65,6 @@ - - Project Managers: all tasks from all projects -- cgit v1.2.3 From eda8c647284ec1fa210f75cd47d341209d854e26 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 8 Apr 2013 11:08:41 +0200 Subject: [FIX] Adjust rules also for issue bzr revid: jco@openerp.com-20130408090841-b2evc2374wetnv06 --- addons/project/security/project_security.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/project') diff --git a/addons/project/security/project_security.xml b/addons/project/security/project_security.xml index 5374549d9ed..78da9284f9f 100644 --- a/addons/project/security/project_security.xml +++ b/addons/project/security/project_security.xml @@ -47,21 +47,21 @@ Public Members - ['|',('privacy_visibility','in',['public', 'publicall', 'employees']),('message_follower_ids','in',[user.partner_id.id])] + - Task multi-company + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] Tasks According to User and Project - ['|','|','|','|',('project_id.visibility', '=', 'publicall'),('user_id','=',False),('user_id','=',user.id),('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)] + ['|','|','|','|',('project_id.privacy_visibility', '=', 'publicall'),('user_id','=',False),('user_id','=',user.id),('project_id.members','in', [user.id]),('project_id.user_id','=',user.id)] -- cgit v1.2.3 From a3de5c872f7c26ec085dc62b95cfc62382ab970a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 9 Apr 2013 13:11:58 +0200 Subject: [REF] [IMP] mail_alias improvement alias_name is not required anymore crm, hr_job, project, mail_group, res_users: alias creation is now different and done more like other inherits, except an alias_model_name that is given to the context to find the alias alias_model_id. crm, jr_job, project, mail_group, res_users: updated form views using aliases mail_alias: added a filter on 'inactive' aliases (alias_name False) and added a button to redirect to the related document if any bzr revid: tde@openerp.com-20130409111158-bv04n5o01z9l3c17 --- addons/project/project.py | 32 ++++++++++++-------------------- addons/project/project_view.xml | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 31 deletions(-) (limited to 'addons/project') diff --git a/addons/project/project.py b/addons/project/project.py index eb328007d44..b580965e8f4 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -348,13 +348,11 @@ class project(osv.osv): default['state'] = 'open' default['line_ids'] = [] default['tasks'] = [] - default.pop('alias_name', None) - default.pop('alias_id', None) proj = self.browse(cr, uid, id, context=context) if not default.get('name', False): default.update(name=_("%s (copy)") % (proj.name)) res = super(project, self).copy(cr, uid, id, default, context) - self.map_tasks(cr,uid,id,res,context) + self.map_tasks(cr, uid, id, res, context=context) return res def duplicate_template(self, cr, uid, ids, context=None): @@ -505,7 +503,7 @@ def Project(): for project in projects: project_gantt = getattr(projects_gantt, 'Project_%d' % (project.id,)) for task in project.tasks: - if task.state in ('done','cancelled'): + if task.state in ('done', 'cancelled'): continue p = getattr(project_gantt, 'Task_%d' % (task.id,)) @@ -525,23 +523,17 @@ def Project(): # ------------------------------------------------ def create(self, cr, uid, vals, context=None): - if context is None: context = {} - # Prevent double project creation when 'use_tasks' is checked! - context = dict(context, project_creation_in_progress=True) - mail_alias = self.pool.get('mail.alias') - if not vals.get('alias_id') and vals.get('name', False): - alias_name = vals.pop('alias_name', None) # prevent errors during copy() - alias_id = mail_alias.create_unique_alias(cr, uid, - # Using '+' allows using subaddressing for those who don't - # have a catchall domain setup. - {'alias_name': alias_name or "project+"+short_name(vals['name'])}, - model_name=vals.get('alias_model', 'project.task'), - context=context) - vals['alias_id'] = alias_id - if vals.get('type', False) not in ('template','contract'): + if context is None: + context = {} + # Prevent double project creation when 'use_tasks' is checked + alias management + create_context = dict(context, project_creation_in_progress=True, alias_model_name=self._name) + + if vals.get('type', False) not in ('template', 'contract'): vals['type'] = 'contract' - project_id = super(project, self).create(cr, uid, vals, context) - mail_alias.write(cr, uid, [vals['alias_id']], {'alias_defaults': {'project_id': project_id} }, context) + + project_id = super(project, self).create(cr, uid, vals, context=create_context) + project_rec = self.browse(cr, uid, project_id, context=context) + self.pool.get('mail.alias').write(cr, uid, [project_rec.alias_id.id], {'alias_defaults': {'project_id': project_id}}, context) return project_id def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index a016c46e0e0..5a1f03823a2 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -89,16 +89,16 @@
-
+ attrs="{'invisible': [('alias_domain', '=', False)]}"> + + %% + + + + %% + @ + +
- - - - Date: Fri, 10 May 2013 12:21:47 +0200 Subject: [IMP] project, hr, crm: improved form views about email aliases... another iteration of improvement. bzr revid: tde@openerp.com-20130510102147-fq98n6qf88a45ti0 --- addons/project/project_view.xml | 58 +++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'addons/project') diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 1f980e659b3..303808463fb 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -99,26 +99,32 @@