콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
12167 화면

Hi all. I dont know :"'ascii' codec can't decode byte 0xc3 in position 32: ordinal not in range(128)" what is an error? Can you suggest to me?

My code .py

     
    _columns = {
                'state': fields.selection([('draft', 'Kiến nghị'),('cancel', 'Đã hủy'),('done', 'Đã xác nhận') ], 'Trạng thái', readonly=True,track_visibility='onchange'),
                
                'ma_nv':fields.many2one('danh.sach.nv', 'Mãy NV'),
                'ten_nv':fields.char('Tên nhân', size = 40),
                'ten_bp':fields.many2one('bo.phan', 'Bộ phận'),
                'ten_cd':fields.many2one('chuc.danh', 'Chức danh'),
                'luong_ct':fields.char( 'Lương chính thức', size =  20),
                'luong_dc':fields.char('Lương điều chỉnh', size = 20),
                'ly_do_dc': fields.char('Lý do điều chỉnh', size = 30),
                'date_confirm': fields.date('Date Confirm', readonly=True, select=True, help="Date on which sales order is confirmed."),
                }
    _default = {
                'state' : 'draft'}
    
    def unlink(self, cr, uid, ids, context=None):
        sale_orders = self.read(cr, uid, ids, ['state'], context=context)
        unlink_ids = []
        for s in sale_orders:
            if s['state'] in ['draft', 'cancel']:
                unlink_ids.append(s['id'])
            else:
                raise osv.except_osv(('Khong hop le'),('Ban phai xac nhan truoc khi huy bo'))

            return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
    
    def action_confirm(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids,{'state': 'done', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
        return True
    def action_cancel(self, cr, uid, ids, context = None):
        self.write(cr, uid, ids, {'state': 'cancel'})  

아바타
취소
베스트 답변

Try to declare your string as unicode, for example :

('draft', 'Kiến nghị') becomes ('draft', u'Kiến nghị').

But I would recommend you to write your code in english, use _() i18n function and then translate your text with poedit. It's also much easier for other people who don't speak your language to support you on this forum.

 

More reading about encoding/decoding and unicode.

https://docs.python.org/2/howto/unicode.html

아바타
취소
작성자 베스트 답변

Thanks Cyril Sester !

 

아바타
취소
관련 게시물 답글 화면 활동
2
4월 21
69971
3
3월 15
8533
2
12월 16
4778
0
11월 16
6513
0
8월 16
4356