[IMP:moved _check_dates function from module project_long_term to module project]
authorpap (openerp) <pap@tinyerp.co.in>
Wed, 20 Jan 2010 12:44:10 +0000 (18:14 +0530)
committerpap (openerp) <pap@tinyerp.co.in>
Wed, 20 Jan 2010 12:44:10 +0000 (18:14 +0530)
bzr revid: pap@tinyerp.co.in-20100120124410-gl06rvx06c4vo1xw

addons/project/project.py
addons/project_long_term/project.py

index 89cf75e..0865c24 100644 (file)
@@ -324,13 +324,13 @@ class task(osv.osv):
         default['work_ids'] = []
         return super(task, self).copy_data(cr, uid, id, default, context)
 
-       def _check_date(self,cr,uid,ids):
-            for res in self.browse(cr,uid,ids):
-                if res.date_start and res.date_end:
-                    if res.date_start > res.date_end:
-                        return False
-                    return True
-
+    def _check_dates(self, cr, uid, ids):
+         task = self.read(cr, uid, ids[0],['date_start','date_end'])
+         if task['date_start'] and task['date_end']:
+             if task['date_start'] > task['date_end']:
+                 return False
+         return True
+     
     _columns = {
         'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the task without removing it."),
         'name': fields.char('Task summary', size=128, required=True),
@@ -380,6 +380,9 @@ class task(osv.osv):
     }
     _order = "sequence, priority, date_deadline, id"
 
+    _constraints = [
+        (_check_dates, 'Error! task start-date must be lower then task end-date.', ['date_start', 'date_end'])
+    ]
     #
     # Override view according to the company definition
     #
index c573426..3f16b33 100644 (file)
@@ -125,17 +125,6 @@ class task(osv.osv):
     _columns = {
         'phase_id': fields.many2one('project.phase', 'Project Phase')
     }
-    def _check_dates(self, cr, uid, ids):
-         leave = self.read(cr, uid, ids[0],['date_start','date_end'])
-         if leave['date_start'] and leave['date_end']:
-             if leave['date_start'] > leave['date_end']:
-                 return False
-         return True
-
-    _constraints = [
-        (_check_dates, 'Error! task start-date must be lower then task end-date.', ['date_start', 'date_end'])
-    ]
-
 task()
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: