hr_holidays : 1. bug fix for calculating remaining leaves 2. add constraints for date field
bzr revid: mra@tinyerp.com-20090316130746-3ge8h2mu2u47p1nx
This commit is contained in:
parent
5285c6cbaf
commit
7a9ef2b535
|
@ -69,9 +69,9 @@ class hr_holidays_per_user(osv.osv):
|
|||
|
||||
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
|
||||
obj_holiday = self.pool.get('hr.holidays')
|
||||
days = 0.0
|
||||
result = {}
|
||||
for holiday_user in self.browse(cr, uid, ids):
|
||||
days = 0.0
|
||||
ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
|
||||
if ids_request:
|
||||
holidays = obj_holiday.browse(cr, uid, ids_request)
|
||||
|
@ -130,6 +130,16 @@ class hr_holidays(osv.osv):
|
|||
}
|
||||
_order = 'date_from desc'
|
||||
|
||||
def _check_date(self, cr, uid, ids):
|
||||
if ids:
|
||||
cr.execute('select number_of_days from hr_holidays where id in ('+','.join(map(str, ids))+')')
|
||||
res = cr.fetchall()
|
||||
if res and res[0][0] < 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [(_check_date, 'Start date should not be larger than end date! ', ['number_of_days'])]
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs)
|
||||
self._create_holiday(cr, uid, [id_holiday])
|
||||
|
|
Loading…
Reference in New Issue