Corrected behaviour of project with o hours and one task defined

bzr revid: jvo@tinyerp.com-20090101110323-gsv6p3c3ab2dm7hr
This commit is contained in:
Jay (Open ERP)
2009-01-01 16:33:23 +05:30
parent 4f9faa7f00
commit c3ec67cc57
+4
View File
@@ -409,11 +409,15 @@ class project_work(osv.osv):
}
_order = "date desc"
def create(self, cr, uid, vals, *args, **kwargs):
if 'hours' in vals and (not vals['hours']):
vals['hours'] = 0.00
if 'task_id' in vals:
cr.execute('update project_task set remaining_hours=remaining_hours - %s where id=%s', (vals.get('hours',0.0), vals['task_id']))
return super(project_work,self).create(cr, uid, vals, *args, **kwargs)
def write(self, cr, uid, ids,vals,context={}):
if 'hours' in vals and (not vals['hours']):
vals['hours'] = 0.00
for work in self.browse(cr, uid, ids, context):
cr.execute('update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s', (vals.get('hours',0.0), work.hours, work.task_id.id))
return super(project_work,self).write(cr, uid, ids, vals, context)