From a6909d0cc0960163d00d5065fb4df50fbf1e0882 Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Wed, 20 Jan 2010 18:14:10 +0530 Subject: [PATCH] [IMP:moved _check_dates function from module project_long_term to module project] bzr revid: pap@tinyerp.co.in-20100120124410-gl06rvx06c4vo1xw --- addons/project/project.py | 17 ++++++++++------- addons/project_long_term/project.py | 11 ----------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/addons/project/project.py b/addons/project/project.py index 89cf75e454c..0865c24857b 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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 # diff --git a/addons/project_long_term/project.py b/addons/project_long_term/project.py index c5734263ea5..3f16b33ea31 100644 --- a/addons/project_long_term/project.py +++ b/addons/project_long_term/project.py @@ -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: