[FIX] project: default stage on task

If you create a task directly, the key `default_project_id` is not set
in the context. This key is used to compute the default stage of the
created task. It is done by creating a domain. Unfortunately, the
domain is always filled with `[('fold', '=', False)]` and thus it
always returns a result that makes no sense when `default_project_id`
is not set. Worse, if you actually create the task, the found stage
that was not in your project is now a part of it.

The fix is to return no result if the `default_project_id` is not set
in the context.
This commit is contained in:
Simon Lejeune
2016-08-30 15:45:15 +02:00
parent 5100aa8113
commit 7d3f9ac9b9
+4 -1
View File
@@ -358,7 +358,10 @@ class task(osv.osv):
""" Gives default stage_id """
if context is None:
context = {}
return self.stage_find(cr, uid, [], context.get('default_project_id'), [('fold', '=', False)], context=context)
default_project_id = context.get('default_project_id')
if not default_project_id:
return False
return self.stage_find(cr, uid, [], default_project_id, [('fold', '=', False)], context=context)
def _read_group_stage_ids(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
if context is None: