我的代码中存在问题:
def exam_day_date (self,day_id_date):
id_date= []
self._cr.execute(
"""select week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids from fci_exam_time_table_line, fci_subject s ,rel_sa t,lgna_teacher y where exam_id = %d group by week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids order by exam_date """ % (
day_id_date))
res = self._cr.dictfetchall()
self._cr.execute(
"""select week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids from fci_exam_time_table_line, fci_subject s ,rel_sa t,lgna_teacher y where exam_id = %d group by week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids order by exam_date """ % (
day_id_date))
time_data = self._cr.dictfetchall()
for time_detail in time_data:
for data in res:
time_detail[data['week_day']] = '('+data['week_day']+')\n'+data['exam_date']+'\n('+data['name']+')'+data['sasa_zozo']+data['teacher_ids']
id_date.append(time_detail)
print (id_date)
return id_date
其中week_day,名称为chars,exam_date为日期,但sasa_zozo和teacher_ids为intgers
当我尝试打印报告时,它会给我错误
答案 0 :(得分:1)
将整数转换为字符串并将其传递给报告模板进行打印
def exam_day_date (self,day_id_date):
id_date= []
self._cr.execute(
"""select week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids from fci_exam_time_table_line, fci_subject s ,rel_sa t,lgna_teacher y where exam_id = %d group by week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids order by exam_date """ % (
day_id_date))
res = self._cr.dictfetchall()
self._cr.execute(
"""select week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids from fci_exam_time_table_line, fci_subject s ,rel_sa t,lgna_teacher y where exam_id = %d group by week_day,exam_date ,s.name,t.sasa_zozo,y.teacher_ids order by exam_date """ % (
day_id_date))
time_data = self._cr.dictfetchall()
for time_detail in time_data:
for data in res:
time_detail[data['week_day']] = '('+data['week_day']+')\n'+data['exam_date']+'\n('+data['name']+')'+str(data['sasa_zozo'])+str(data['teacher_ids'])
id_date.append(time_detail)
print (id_date)
return id_date
你试图将一个整数附加到一个字符串,这就是错误的原因