From 7d3f9ac9b944c616202ff10b2cf2d8ddf8d41871 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Tue, 30 Aug 2016 15:45:15 +0200 Subject: [PATCH] [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. --- addons/project/project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/project/project.py b/addons/project/project.py index 07e22984245..ce0857724cb 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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: