Corrected behaviour of project with o hours and one task defined
authorJay (Open ERP) <jvo@tinyerp.com>
Thu, 1 Jan 2009 11:03:23 +0000 (16:33 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Thu, 1 Jan 2009 11:03:23 +0000 (16:33 +0530)
bzr revid: jvo@tinyerp.com-20090101110323-gsv6p3c3ab2dm7hr

addons/project/project.py

index b7779bb..6a1e1df 100644 (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)