我有一个名为populate_attendance_normal_shift
的函数。我将使用它来填充我的数据库中的一个表,我打算用openerp调度程序在其中运行。但问题是我不知道如何只用这个功能才能做到这一点。
我已经测试了它作为onchange功能,打印了一些值,直到它工作得非常好。 现在我需要的是用这些值填充表格。我的功能是这样的......
def populate_attendance_normal_shift(self,cr,uid,ids,context=None):
#The function wich will populate the Allowance Attendance Table.
#Either the person will work as a roster basis or normal hours, This is the table need to get populated.
result = {'value': {}}
all_emp_id=0
all_emp_type=""
gt_dt=cr.execute("""SELECT ap.id,
ap.sign_in,
ap.sign_out,
ap.reldate,
ap.day_type,
ap.sign_in2,
ap.sign_out2,
emp.id,
emp.employee_no,
emp.category,
emp.department_id,
emp.gender,
emp.comp_id,
emp.departmnt_id,
emp.division_id,
emp.sec_id
FROM attendance_processed ap
INNER JOIN hr_employee emp
ON ap.employe_name = emp.id
WHERE ((TO_TIMESTAMP(ap.sign_out, 'HH24:MI')::TIME)>(TO_TIMESTAMP('18:00', 'HH24:MI')::TIME))
AND (((TO_TIMESTAMP(ap.sign_out, 'HH24:MI')::TIME)-(TO_TIMESTAMP('18:00', 'HH24:MI')::TIME))> INTERVAL '4 hour')
AND (to_date(ap.reldate, 'YY-MM-DD') >= CURRENT_TIMESTAMP - INTERVAL '45 days')""")
gt_dd=cr.fetchall()
if gt_dd:
i=0
for n in gt_dd:
all_att_id=n[0]
all_sign_in=n[1].encode("utf-8")
all_sign_out=n[2].encode("utf-8")
all_date=n[3].encode("utf-8")
all_day=n[4].encode("utf-8")
all_sign_in2=n[5]
all_sign_out2=n[6]
all_emp_id=n[7]
all_emp_no=n[8]
all_emp_cat=n[9]
all_emp_dept_id=n[10]
all_emp_gen=n[11]
all_emp_comp=n[12]
all_emp_dept=n[13]
all_emp_divi=n[14]
all_emp_sec=n[15]
#all_emp_sec_name=n[15]
emp_obj=cr.execute("""select ec.name from hr_employee e, employee_category_rel ecr, hr_employee_category ec
where e.id = ecr.emp_id and ec.id = ecr.category_id and e.employee_no='%s' and ec.name = 'Roster' """%(all_emp_no))
if emp_obj:
all_emp_type="Roster"
else:
all_emp_type="Normal"
cat_id = self.pool.get('hr.category').browse(cr, uid, all_emp_cat, context=None).priority
chk_id=cr.execute("""SELECT id FROM allowance_attendances WHERE attendance_id=%d"""%(all_att_id))
if not chk_id:
print "^^^^^ This is where I checked the values^^^^^"
print all_att_id#
print all_sign_in#
print all_sign_out#
print all_date#
print all_day#
print all_emp_id
print all_emp_no
print all_emp_cat
print all_emp_dept_id
print all_emp_comp
print all_emp_dept
print all_emp_divi
print all_emp_sec
print all_emp_type
print cat_id
if (all_sign_in and all_sign_out)or(all_sign_in2 and all_sign_out2):
# self.get_number_of_hours(cr, uid, ids, all_date, all_sign_in, all_sign_out,all_sign_in2,all_sign_out2, all_emp_type, context)
print "###### This is where I don't know how to do it#######"
# result['value']['employee_id'] =all_emp_id
# result['value']['catagory_id'] =cat_id
# result['value']['attendance_id'] =all_att_id
# result['value']['date'] =all_date
# result['value']['day'] =all_day
# result['value'][''] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
# result['value']['extra_hours'] =comp_hours
test_id=self.create(cr, uid, {
'employee_id':all_emp_id,
'catagory_id':cat_id,
'attendance_id':all_att_id,
'date':all_date,
#'day' :all_day
})
#def write / update kathawa liyanna
else:
print "Next part coming soon"
return True