From d72306939b1fc1ff30f1f06a2bf9f3e472a28f42 Mon Sep 17 00:00:00 2001 From: "Rvo (Open ERP)" Date: Fri, 26 Feb 2010 19:30:28 +0530 Subject: [PATCH] [ADD] constraints on constraint date start and constrint date end for phase's start and end bzr revid: rvo@tinyerp.co.in-20100226140028-fdgt9ltb4k7xue2r --- addons/project_long_term/project.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/project_long_term/project.py b/addons/project_long_term/project.py index df21511434f..5bad633e7b0 100644 --- a/addons/project_long_term/project.py +++ b/addons/project_long_term/project.py @@ -78,6 +78,19 @@ class project_phase(osv.osv): return False return True + def _check_constraint_start(self, cr, uid, ids): + phase = self.read(cr, uid, ids[0],['date_start','constraint_date_start']) + if phase['date_start'] and phase['constraint_date_start']: + if phase['date_start'] < phase['constraint_date_start']: + return False + return True + + def _check_constraint_end(self, cr, uid, ids): + phase = self.read(cr, uid, ids[0],['date_end','constraint_date_end']) + if phase['date_end'] and phase['constraint_date_end']: + if phase['date_end'] > phase['constraint_date_end']: + return False + return True _columns = { 'name': fields.char("Phase Name", size=64, required=True), @@ -110,7 +123,10 @@ class project_phase(osv.osv): _order = "name" _constraints = [ (_check_recursion,'Error ! Loops In Phases Not Allowed',['next_phase_ids','previous_phase_ids']), - (_check_dates, 'Error! Phase start-date must be lower then Phase end-date.', ['date_start', 'date_end']) + (_check_dates, 'Error! Phase start-date must be lower then Phase end-date.', ['date_start', 'date_end']), + (_check_constraint_start, 'Error! Phase must start-after Constraint Start Date.', ['date_start', 'constraint_date_start']), + (_check_constraint_end, 'Error! Phase must end-before Constraint End Date.', ['date_end', 'constraint_date_end']), + ] def onchange_project(self,cr,uid,ids,project):