Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

'ascii' codec can't decode byte 0xc3 in position 2: ordinal not in range(128)

By
huongcute
on 8/28/14, 3:04 AM 1,992 views

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

3
Cyril Sester
On 8/28/14, 3:33 AM

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

0
huongcute
On 8/28/14, 5:41 AM

Thanks Cyril Sester !

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/28/14, 3:04 AM
Seen: 1992 times
Last updated: 3/16/15, 8:10 AM