Bonjour,
Suis débutant dans OpenERP et Phython.
Dans une édition, dans la première colonne, est imprimer le mois en lettre en l'année.
Lorsque le mois comporte un accent (Février, Août, Décembre) le rapport plante pour cause de caractère Unicode non reconnu.
J'ai besoin de votre aide. merci
Voici le code:
-l'inisialisation :
- Le code où cela plante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 ym_desc = {} for prod_data in prod_datas: tdate = datetime.datetime.strptime(prod_data.date, '%Y-%m-%d') ym = tdate.strftime('%Y-%m') ore_cat = prod_data.ore_type_id.category ore_code = prod_data.ore_type_id.code volume = prod_data.volume_of_ore weight = prod_data.weight_of_ore if(ym not in ym_desc): #check base/res/res_lang.py line 56-62 lang = context.get('lang','en_US') for ln in tools.get_locales(lang): try: locale.setlocale(locale.LC_ALL, str(ln)) break except locale.Error: continue #set month year description ym_desc[ym] = tdate.strftime('%B %Y')
Enfin, l'erreur affichée:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 row_xml = { 'month' : [], 'ending' : [] } for key, row in rows: if key != 'ending': tkey = 'month' ---> row_xml[tkey].append('<row monthYear="%s">' % (ym_desc[key])) else: tkey = 'ending' row_xml[tkey].append('<row>')
J'ai essayé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 utf8 <row monthYear="août 2014"> 18 23 unsupported Unicode code range (<type 'exceptions.UnicodeDecodeError'>, UnicodeDecodeError('utf8', '<row monthYear="ao\xfbt 2014">', 18, 23, 'unsupported Unicode code range'), <traceback object at 0x03AE3328>)
Mais sans succès.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ym_utf8 = tdate.strftime('%B %Y') ym_desc[ym] = unicode( ym_utf8 , 'UTF8')
Mille merci pour votre aide
Partager