تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
12044 أدوات العرض

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
أبريل 21
69775
3
مارس 15
8356
2
ديسمبر 16
4699
0
نوفمبر 16
6414
0
أغسطس 16
4264