Odoo Help


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.


unicode decode error

on 4/17/13, 12:37 AM 3,451 views

Hi, am using a res_partner inherit module and i have a field.char. But the probleme i have is, where i fill this field to create the object i get this error "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)"

Help me please


Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 4/17/13, 5:32 PM

Make sure your module does not do str(xyz) where xyz is accented string! tools.ustr() should help.

I'am sure my module does not do str(xyz),

on 4/19/13, 10:18 AM

Please paste the whole traceback.

Serpent Consulting Services Pvt. Ltd.
on 4/19/13, 2:09 PM

Here it is Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 195, in dispatch response["result"] = method(self, *self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1079, in call_kw return self._call_kw(req, model, method, args, kwargs) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1071, in _call_kw return getattr(req.session.model(model), method)(args, **kwargs) File "/opt/openerp/server/openerp/addons/web/session.py", line 43, in proxy result = self.proxy.

on 4/19/13, 2:28 PM

Are you using V6 or v7? I suspect real error is at server side and client just being unable to convert the error, throws this. Would you please mind to check the server log?

Serpent Consulting Services Pvt. Ltd.
on 4/19/13, 4:21 PM

In Python, unicode and str are two different data types. When Python tries to implicitly convert between one and the other, it uses encode (unicode -> str) and decode (str -> unicode). In OpenERP, text is actually Unicode. Encode and decode errors like your one can be avoided with some understanding of how Unicode works in Python. Ned Batchelder made an excellent presentation on the subject, google "unicode pain python".



| 2 1 4
Buenos Aires, Argentina

Python developer, big fan of sailing

On 4/17/13, 10:56 AM

You need to change the encoding of the data you are updating your model with. Do this in your module:


it might work (as long your input data was encoded with cp1252)

On 4/19/13, 10:19 AM

I can not do string_variable.decode('cp1252') because values are in the form create i do not treat them before they are stored

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

0 follower(s)


Asked: 4/17/13, 12:37 AM
Seen: 3451 times
Last updated: 3/16/15, 8:10 AM