Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
12177 Tampilan

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'})  

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Penulis Jawaban Terbai

Thanks Cyril Sester !

 

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Apr 21
69987
3
Mar 15
8552
2
Des 16
4779
0
Nov 16
6526
0
Agu 16
4364