From 3041efb655814a8b18f1f55b01971fa71e89f3a2 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Tue, 30 Aug 2016 16:17:47 +0200 Subject: [PATCH] [FIX] project: task: correctly set stage_id during onchange project_id If you create a task when `default_project_id` is set, the stage_id is initialized at the lowest sequence of the stages of the project, which is normal. However, when you change the project of the task, the stage_id was not correctly reset. If you save at this time, you add the selected stage in the project. Also, the stage_id was not correctly cleared if you remove the project. --- addons/project/project.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index ce0857724cb..927ce38dd40 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -399,11 +399,16 @@ class task(osv.osv): @api.cr_uid_ids_context def onchange_project(self, cr, uid, id, project_id, context=None): + values = {} if project_id: project = self.pool.get('project.project').browse(cr, uid, project_id, context=context) if project and project.partner_id: - return {'value': {'partner_id': project.partner_id.id}} - return {} + values['partner_id'] = project.partner_id.id + values['stage_id'] = self.stage_find(cr, uid, [], project_id, [('fold', '=', False)], context=context) + else: + values['stage_id'] = False + values['partner_id'] = False + return {'value': values} def onchange_user_id(self, cr, uid, ids, user_id, context=None): vals = {}