我一直试图覆盖(def get_worked_day_lines)以获得每个员工的time_sheet_sheet.sheet总出勤率,因此我可以根据total_attendance为他赚取工资单。
class hr_payslip(osv.osv):
_inherit = 'hr.payslip'
_columns = {
}
def get_worked_day_lines(self, cr, uid, ids, employee_id, date_to, context=None):
res = []
working_days = self.pool.get('hr_timesheet_sheet.sheet')
for record in self.browse(cr, uid, ids, context = context):
search_sheet = working_days.search(cr, uid, [('state','=','draft')])
for rec in working_days.browse(cr, uid, search_sheet, context=None):
attendances = {
'name': _("Normal Working Days paid at 100%"),
'sequence': 1,
'code': 'WORK100',
'number_of_days': 0.0,
'number_of_hours': 0.0,
#'contract_id': ,
}
if rec.day == record.numero :
attendances['code'] = rec.day
leaves = {}
leaves = [value for key,value in leaves.items()]
res += [attendances] + leaves
return res
ps:我放的时候
search_sheet = working_days.search(cr, uid,[('state','=','draft')])
我将能够从所有草稿时间表中获得total_attendance
output for search_sheet = working_days.search(cr, uid,[('state','=','draft')])
答案 0 :(得分:0)
我实际上在OpenERP v7上工作,所以我知道这里发生了什么。如果您没有使用[(' employee_id',' =',employee_id)]搜索条件获得任何内容,那么因为employee_id参数的值,所以&# 39; t等于数据库中的任何employee_id。
您应该做的是检查作为函数参数传入的employee_id的值。如果值是整数,则检查数据库中是否存在该ID。如果该表上存在该ID,您应该看到数据。如果employee_id的值为False或None,那么您将无法从搜索中获取任何数据()