Hi I am trying to count no of days the employee signed in so to count no of presents in the office in a month
please help me
I am thinking if i iterate through the hr.attendance module to count no of days
class esteem_payslip(osv.osv):
_inherit = 'hr.payslip'
def prasent_days(self, cr, uid, ids, field_names, args, context=None):
res={}
user_att = self.pool.get("hr.attendance")
for slip in self.browse(cu, uid, ids, context=None):
temp = 0
att_ids = user_att.search(cu, uid, [('employee_id','=',slip.employee_id.id)])
for count in user_att.browse(cu, uid, att_ids, context=None):
if count.name >= slip.date_from and count.name <= slip.date_to: #This is not a good condition
temp = temp + 1.0
res[id]=temp
return res
_columns = {
'es_present':fields.function(prasent_days, "No.of Present Days"),
}
esteem_payslip()
this is not working
att_ids = user_att.search(cr, uid, [('employee_id','=',slip.employee_id.id)])
NameError: global name 'cr' is not defined