[FIX] code cleanup (addon hr_holidays)
improves th _leaves_count method, and remove an useless one2many field (leaves_ids) bzr revid: ged@openerp.com-20140507083556-rqm5sllj8fc3qfev
This commit is contained in:
parent
b08e0b0fe1
commit
cc041c516a
|
@ -550,13 +550,11 @@ class hr_employee(osv.osv):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _leaves_count(self, cr, uid, ids, field_name, arg, context=None):
|
def _leaves_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||||
res = dict(map(lambda x: (x,0), ids))
|
Holidays = self.pool['hr.holidays']
|
||||||
try:
|
return {
|
||||||
for employee in self.browse(cr, uid, ids, context=context):
|
employee_id: Holidays.search_count(cr,uid, [('employee_id', '=', employee_id)], context=context)
|
||||||
res[employee.id] = len(employee.leave_ids)
|
for employee_id in ids
|
||||||
except:
|
}
|
||||||
pass
|
|
||||||
return res
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'remaining_leaves': fields.function(_get_remaining_days, string='Remaining Legal Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave request. Total based on all the leave types without overriding limit.'),
|
'remaining_leaves': fields.function(_get_remaining_days, string='Remaining Legal Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave request. Total based on all the leave types without overriding limit.'),
|
||||||
|
@ -566,7 +564,6 @@ class hr_employee(osv.osv):
|
||||||
'current_leave_id': fields.function(_get_leave_status, multi="leave_status", string="Current Leave Type",type='many2one', relation='hr.holidays.status'),
|
'current_leave_id': fields.function(_get_leave_status, multi="leave_status", string="Current Leave Type",type='many2one', relation='hr.holidays.status'),
|
||||||
'leave_date_from': fields.function(_get_leave_status, multi='leave_status', type='date', string='From Date'),
|
'leave_date_from': fields.function(_get_leave_status, multi='leave_status', type='date', string='From Date'),
|
||||||
'leave_date_to': fields.function(_get_leave_status, multi='leave_status', type='date', string='To Date'),
|
'leave_date_to': fields.function(_get_leave_status, multi='leave_status', type='date', string='To Date'),
|
||||||
'leave_ids': fields.one2many('hr.holidays', 'employee_id', 'Leaves'),
|
|
||||||
'leaves_count': fields.function(_leaves_count, type='integer', string='Leaves'),
|
'leaves_count': fields.function(_leaves_count, type='integer', string='Leaves'),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue