[FIX] project: Don't reset partner_id in onchange_project when empty

In 3041efb, it was introduced a partner_id reset when project_id is
False, but this causes you can't apply default values to partner_id
directly.

One use case where happens:

* Go to Sales > Customers.
* Select one customer.
* Click on the smart-button "Tasks".
* Create new task.

Before this commit, the customer where you come from is assigned.
After this, no partner is selected.
This commit is contained in:
Pedro M. Baeza
2017-01-11 17:20:27 +01:00
committed by Simon Lejeune
parent ea4c231130
commit 3aa7b8ca27
+3 -4
View File
@@ -402,12 +402,11 @@ class task(osv.osv):
values = {}
if project_id:
project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
if project and project.partner_id:
values['partner_id'] = project.partner_id.id
values['stage_id'] = self.stage_find(cr, uid, [], project_id, [('fold', '=', False)], context=context)
if project.exists():
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):