Merge lp:~openerp-dev/openobject-addons/7.0-opw-605218-ado into lp:openobject-addons/7.0

Proposed by Amit Dodiya (OpenERP)
Status: Superseded
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-605218-ado
Merge into: lp:openobject-addons/7.0
Diff against target: 29 lines (+13/-0)
1 file modified
project/project.py (+13/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-605218-ado
Reviewer Review Type Date Requested Status
Amit Dodiya (OpenERP) (community) Needs Resubmitting
Denis Ledoux (OpenERP) Disapprove
Naresh(OpenERP) Pending
Review via email: mp+212089@code.launchpad.net

This proposal has been superseded by a proposal from 2014-03-31.

Description of the change

Hello,

[FIX] project: users are able to create tasks on closed project and also able to see the closed project on dropdown list(of project) on task form

1st Issue - User is able to search the closed project on many2one dropdown on task form:
Steps:
1). Create a new project(for e.g: test), cancel it
2). Now create a task from task menu and type test on many2one field of project
You will find the closed project on list

2nd Issue - User is able to create task from closed project by opening tasks menu from Tasks button on project form:
Steps:
1). Create a new project(for e.g: test), cancel it
2). Now you have tasks button on project, click on it and try to create task
You will see the task is created from that closed project

Regards,
Amit Dodiya

To post a comment you must log in.
Revision history for this message
Denis Ledoux (OpenERP) (dle-openerp) wrote :

While it seems indeed right to not attach tasks to closed projects, you should not prevent totally user to do so.

In a general matter, we have to keep OpenERP as generic as possible, and this is possible that some users want to be able to attach tasks to closed projects.

Nevertheless, you can help them to avoid doing this mistake by adding a domain on the project field on the tasks view. One line patch.

review: Disapprove
Revision history for this message
Amit Dodiya (OpenERP) (ado-openerp) wrote :

Hello Denis,

I have improved the code as per the suggestion.

Regards,
Amit

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'project/project.py'
2--- project/project.py 2014-02-06 17:27:02 +0000
3+++ project/project.py 2014-03-21 06:10:55 +0000
4@@ -575,6 +575,15 @@
5 model_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', vals.get('alias_model', 'project.task'))])
6 vals.update(alias_model_id=model_ids[0])
7 return super(project, self).write(cr, uid, ids, vals, context=context)
8+
9+ def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
10+ if not args:
11+ args = []
12+ if context is None:
13+ context = {}
14+ ids = self.search(cr, uid, [('state', '!=', 'close'), ('name', operator, name)] + args, limit=limit, context=context)
15+ return self.name_get(cr, uid, ids, context or {})
16+
17
18 class task(base_stage, osv.osv):
19 _name = "project.task"
20@@ -1125,6 +1134,10 @@
21 def create(self, cr, uid, vals, context=None):
22 if context is None:
23 context = {}
24+ if vals.get('project_id'):
25+ project_record = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context)
26+ if project_record.state == 'close':
27+ raise osv.except_osv(_('Warning !'), _('You can not create tasks on closed project.'))
28 if vals.get('project_id') and not context.get('default_project_id'):
29 context['default_project_id'] = vals.get('project_id')
30