[product_images] uploading an images with an accentuated name -> UnicodeEncodeError: 'ascii' codec can't encode character

Bug #1197996 reported by Raphaël Valyi - http://www.akretion.com
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenERP Product Attributes
Incomplete
Undecided
Unassigned

Bug Description

on rev trunk #207
For instance uploading an images named réception.png will result in such stack trace:

Server Traceback (most recent call last):
  File "/home/erp_super/erp/prod/src/web/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/erp_super/erp/prod/src/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/erp_super/erp/prod/src/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/erp_super/erp/prod/src/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/erp_super/erp/prod/src/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/erp_super/erp/prod/src/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/erp_super/erp/prod/src/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/erp_super/erp/prod/src/product-attributes/product_images/product.py", line 100, in write
    return super(product_product, self).write(cr, uid, ids, vals, context=context)
  File "/home/erp_super/erp/prod/src/product-attributes/product_sequence/product_product.py", line 63, in write
    vals, context=context)
  File "/home/erp_super/erp/prod/src/addons/mail/mail_thread.py", line 275, in write
    result = super(mail_thread, self).write(cr, uid, ids, values, context=context)
  File "/home/erp_super/erp/prod/src/server/openerp/osv/orm.py", line 4179, in write
    result += self._columns[field].set(cr, self, id, field, vals[field], user, context=rel_context) or []
  File "/home/erp_super/erp/prod/src/server/openerp/osv/fields.py", line 557, in set
    id_new = obj.create(cr, user, act[2], context=context)
  File "/home/erp_super/erp/prod/src/product-attributes/product_images/product_images.py", line 51, in create
    return super(product_images, self).create(cr, uid, vals, context=context)
  File "/home/erp_super/erp/prod/src/server/openerp/osv/orm.py", line 4470, in create
    result += self._columns[field].set(cr, self, id_new, field, vals[field], user, rel_context) or []
  File "/home/erp_super/erp/prod/src/server/openerp/osv/fields.py", line 1145, in set
    self._fnct_inv(obj, cr, user, id, name, value, self._fnct_inv_arg, context)
  File "/home/erp_super/erp/prod/src/product-attributes/product_images/product_images.py", line 162, in _set_image
    return self._save_file(full_path, value)
  File "/home/erp_super/erp/prod/src/product-attributes/product_images/product_images.py", line 154, in _save_file
    with open(path, 'w') as ofile:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 61: ordinal not in range(128)

branch with the fix coming right now ;-)

Related branches

Revision history for this message
Joao Alfredo Gama Batista (joao-gama) wrote :

I couldn't reproduce this bug with the given information.

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello Joa,

thanks for having a look. Probably you didn't see the bug because by default images will be stored in the database (very bad BTW).

Can you test again before you should edit the current company (via Settings)
and in the configuration tab, you set the "Images Repository Path" param to something like /tmp/foo and then try to again upload an image with an accentuated name and try to save the product.

If that's of any help, I'm Python 2.7.4 with an UTF-8 locale.

Can you confirm you can reproduce the bug?

Revision history for this message
Joao Alfredo Gama Batista (joao-gama) wrote :

Hi Raphaël,

Actually I did set the "Image Repository Path" from the begining (~/images). I tested again today using accents everywere and it worked for me.

I created a produc with a reference name "Blá" and added an image named "Joé.png". The module created an image in ~/Images/Blá/Joé.png.

Are you sure that your image was not created on a alien filesystem with an alien encoding?

I'm running a Ubuntu 13.04 with python 2.7.4 and fr_FR.UTF-8.

Maybe you can check the file with convmv or attach the image so I can test with your image.

Have a nice day.

Changed in openerp-product-attributes:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.