[Fix] project: assing default in task

lp bug: https://launchpad.net/bugs/691122 fixed

bzr revid: sbh@tinyerp.com-20101217123844-0kavik2g090s4kr7
This commit is contained in:
Sbh (OpenERP) 2010-12-17 18:08:44 +05:30
parent b06f42a215
commit 06c40ea952
2 changed files with 12 additions and 2 deletions

View File

@ -342,7 +342,16 @@ class task(osv.osv):
def onchange_planned(self, cr, uid, ids, planned = 0.0, effective = 0.0):
return {'value':{'remaining_hours': planned - effective}}
def onchange_project(self, cr, uid, id, project_id):
if not project_id:
return {}
data = self.pool.get('project.project').browse(cr, uid, [project_id])
partner_id=data and data[0].parent_id.partner_id
if partner_id:
return {'value':{'partner_id':partner_id.id}}
return {}
def _default_project(self, cr, uid, context=None):
if context is None:
context = {}
@ -476,6 +485,7 @@ class task(osv.osv):
# Override view according to the company definition
#
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
users_obj = self.pool.get('res.users')

View File

@ -211,7 +211,7 @@
<form string="Task edition">
<group colspan="6" col="6">
<field name="name" select="1"/>
<field name="project_id" select="1" domain="[('user_id','=',uid)]"/>
<field name="project_id" select="1" on_change="onchange_project(project_id)" domain="[('user_id','=',uid)]"/>
<field name="total_hours" widget="float_time"/>
<field name="date_deadline" attrs="{'readonly':[('state','in',['done', 'cancelled'])]}"/>
<field name="user_id" select="1" attrs="{'readonly':[('state','in',['done', 'cancelled'])]}"/>