2015-04-05 29 views
0

我在我的代碼中的問題:QWebException:「強迫到Unicode:需要字符串或緩衝區,詮釋發現」,而評估

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,名稱是炭灰和EXAM_DATE是日期,但sasa_zozo和teacher_ids是intgers

當我嘗試打印報告它給了我錯誤

回答

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 
報告模板

你試圖追加一個整數到一個字符串,這就是錯誤的原因

+0

yep解決可能我有另一個問題? – 2015-04-06 16:01:57

+0

Here http://stackoverflow.com/questions/29475077/how-to-retrive-values-in-many2one-field-as-selection-field – 2015-04-06 16:17:09

相關問題