removed duplicate code (ref:pso)
bzr revid: hda@hda-20090417135753-4mkafk3ijv8yk41z
This commit is contained in:
@@ -283,49 +283,6 @@ class hr_holidays(osv.osv):
|
||||
return True
|
||||
hr_holidays()
|
||||
|
||||
|
||||
class hr_holidays_per_user(osv.osv):
|
||||
_name = "hr.holidays.per.user"
|
||||
_description = "Holidays Per User"
|
||||
_rec_name = 'user_id'
|
||||
|
||||
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
|
||||
obj_holiday = self.pool.get('hr.holidays')
|
||||
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)
|
||||
for holiday in holidays:
|
||||
days += holiday.number_of_days
|
||||
days = holiday_user.max_leaves - days
|
||||
result[holiday_user.id] = days
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'employee_id' : fields.many2one('hr.employee', 'Employee',required=True),
|
||||
'user_id' : fields.many2one('res.users','User'),
|
||||
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
|
||||
'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
|
||||
'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
|
||||
'active' : fields.boolean('Active'),
|
||||
'notes' : fields.text('Notes'),
|
||||
'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
|
||||
'history' : fields.one2many('hr.holidays.log', 'holiday_user_id', 'History')
|
||||
}
|
||||
_defaults = {
|
||||
'active' : lambda *a: True,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, *args, **kwargs):
|
||||
if vals['employee_id']:
|
||||
obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
|
||||
vals.update({'user_id': obj_emp.user_id.id})
|
||||
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
|
||||
|
||||
hr_holidays_per_user()
|
||||
|
||||
class holiday_user_log(osv.osv):
|
||||
_name = 'hr.holidays.log'
|
||||
_description = 'hr.holidays.log'
|
||||
|
||||
Reference in New Issue
Block a user