From 0097bfef95d572fc42030a85d813cb0804dfda71 Mon Sep 17 00:00:00 2001 From: "Divyesh Makwana (Open ERP)" Date: Mon, 26 Mar 2012 17:16:29 +0530 Subject: [PATCH 01/13] [IMP] hr_holidays : Improved the field defination, button is properly aligned with state, improve the calendar view and remove the filter. bzr revid: mdi@tinyerp.com-20120326114629-o5yrzqqa93qzuszt --- addons/hr_holidays/hr_holidays.py | 12 ++++++------ addons/hr_holidays/hr_holidays_view.xml | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 3bb7a8e4982..37d51bbef9c 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -118,8 +118,8 @@ class hr_holidays(osv.osv): \nThe state is \'Refused\', when holiday request is refused by manager.\ \nThe state is \'Approved\', when holiday request is approved by manager.'), 'user_id':fields.related('employee_id', 'user_id', type='many2one', relation='res.users', string='User', store=True), - 'date_from': fields.datetime('Start Date', readonly=True, states={'draft':[('readonly',False)]}, select=True), - 'date_to': fields.datetime('End Date', readonly=True, states={'draft':[('readonly',False)]}), + 'date_from': fields.date('Start Date', readonly=True, states={'draft':[('readonly',False)]}, select=True), + 'date_to': fields.date('End Date', readonly=True, states={'draft':[('readonly',False)]}), 'holiday_status_id': fields.many2one("hr.holidays.status", "Leave Type", required=True,readonly=True, states={'draft':[('readonly',False)]}), 'employee_id': fields.many2one('hr.employee', "Employee", select=True, invisible=False, readonly=True, states={'draft':[('readonly',False)]}, help='Leave Manager can let this field empty if this leave request/allocation is for every employee'), #'manager_id': fields.many2one('hr.employee', 'Leave Manager', invisible=False, readonly=True, help='This area is automatically filled by the user who validate the leave'), @@ -186,11 +186,11 @@ class hr_holidays(osv.osv): def _get_number_of_days(self, date_from, date_to): """Returns a float equals to the timedelta between two dates given as string.""" - DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" + DATETIME_FORMAT = "%Y-%m-%d" from_dt = datetime.datetime.strptime(date_from, DATETIME_FORMAT) to_dt = datetime.datetime.strptime(date_to, DATETIME_FORMAT) timedelta = to_dt - from_dt - diff_day = timedelta.days + float(timedelta.seconds) / 86400 + diff_day = timedelta.days return diff_day def unlink(self, cr, uid, ids, context=None): @@ -413,8 +413,8 @@ class hr_employee(osv.osv): def _get_leave_status(self, cr, uid, ids, name, args, context=None): holidays_id = self.pool.get('hr.holidays').search(cr, uid, - [('employee_id', 'in', ids), ('date_from','<=',time.strftime('%Y-%m-%d %H:%M:%S')), - ('date_to','>=',time.strftime('%Y-%m-%d %H:%M:%S')),('type','=','remove'),('state','not in',('cancel','refuse'))], + [('employee_id', 'in', ids), ('date_from','<=',time.strftime('%Y-%m-%d')), + ('date_to','>=',time.strftime('%Y-%m-%d')),('type','=','remove'),('state','not in',('cancel','refuse'))], context=context) result = {} for id in ids: diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml index c01bfe99ad3..f74ca860ec6 100644 --- a/addons/hr_holidays/hr_holidays_view.xml +++ b/addons/hr_holidays/hr_holidays_view.xml @@ -51,6 +51,7 @@ calendar + @@ -86,9 +87,8 @@ - - - + +