Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
11587 Представления

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 !

 

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
апр. 21
68852
3
мар. 15
7756
2
дек. 16
4269
0
нояб. 16
5929
0
авг. 16
3954