[6.0] unlike the GTK client, web-client doesn't accept fields with accentuated chars

Bug #623442 reported by Raphaël Valyi - http://www.akretion.com
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Web Client
Fix Released
High
Sananaz (Open ERP)

Bug Description

Hello,

I think to be truly RAD, Openobject should allow the end user to create new object fields with label in his own language, especially in end user customization or localizations, without the need to deal with all the translation layer (see similar debate here https://bugs.launchpad.net/openobject-server/+bug/613721 )
In the GTK client this works, but not in the we-client.

Try to defined a new sale order field with an accent end display it in the list view or alternatively install the Brazilian localization l10n_br module from here https://code.launchpad.net/~openerp-brazil-team/openerp.pt-br-localiz/trunk

In the web-client sale order list view you will then get that error:

[23/Aug/2010:18:37:20] HTTP Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/cherrypy/_cprequest.py", line 606, in respond
    cherrypy.response.body = self.handler()
  File "/usr/lib/pymodules/python2.6/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/openerp-trunk/web/openobject/tools/_expose.py", line 202, in func_wrapper
    res = func(*args, **kw)
  File "/opt/openerp-trunk/web/openobject/controllers/_root.py", line 37, in default
    return request.handler()
  File "/usr/lib/pymodules/python2.6/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/utils.py", line 124, in wrapper
    return fn(*args, **kw)
  File "/opt/openerp-trunk/web/openobject/tools/_expose.py", line 202, in func_wrapper
    res = func(*args, **kw)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/tree.py", line 283, in open
    'ids': kw.get('id')})
  File "/opt/openerp-trunk/web/addons/openerp/controllers/tree.py", line 242, in do_action
    report_type='pdf')
  File "/opt/openerp-trunk/web/addons/openerp/controllers/actions.py", line 406, in execute_by_keyword
    return execute(action, **data)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/actions.py", line 264, in execute
    search_view = data['search_view'])
  File "/opt/openerp-trunk/web/addons/openerp/controllers/actions.py", line 86, in execute_window
    return Form().create(params)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/utils.py", line 124, in wrapper
    return fn(*args, **kw)
  File "/opt/openerp-trunk/web/openobject/tools/_expose.py", line 202, in func_wrapper
    res = func(*args, **kw)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/form.py", line 202, in create
    form = self.create_form(params, tg_errors)
  File "/opt/openerp-trunk/web/addons/openerp/controllers/form.py", line 193, in create_form
    return tw.form_view.ViewForm(params, name="view_form", action="/openerp/form/save")
  File "/opt/openerp-trunk/web/openobject/widgets/_meta.py", line 40, in wrapper
    res = func(self, *args, **kw)
  File "/opt/openerp-trunk/web/addons/openerp/widgets/form_view.py", line 89, in __init__
    filter_domain=params.filter_domain or [], search_view=params.search_view, group_by_ctx=params.group_by_ctx or [])
  File "/opt/openerp-trunk/web/openobject/widgets/_meta.py", line 40, in wrapper
    res = func(self, *args, **kw)
  File "/opt/openerp-trunk/web/addons/openerp/widgets/search.py", line 269, in __init__
    self.fields_list.sort(lambda x, y: cmp(x[1], y[1]))
  File "/opt/openerp-trunk/web/addons/openerp/widgets/search.py", line 269, in <lambda>
    self.fields_list.sort(lambda x, y: cmp(x[1], y[1]))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)

This is because inside self.fields_list.sort(lambda x, y: cmp(x[1], y[1])), the list of field names will be an heterogenous mix of strings and unicode types. If the fields get it's non ASCII chars just because of the translation layer, then it will be a unicode and that works.
However, if the field has been defined directly with a name having non ASCII chars, then it will be a string and it will generate this error.

It's debatable whether the server fields_view_get method should always return unicode of field names no matter if they have translation or not (may be, then it's up to OpenERP S.A. to make that choice). If this is not done in the server, then here is an attached patch that will encode strings to unicode if this has not been done, so that the cmp operator becomes always successful.

Hope this helps.

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

Hello Raphaël Valyi,

Its fixed in web-client Trunk version. Please update your code and notify us.

Revision-info:
3220 <email address hidden>

Thanks.

Changed in openobject-client-web:
status: New → Confirmed
assignee: nobody → sma (Open ERP) (sma-tiny)
status: Confirmed → Fix Released
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.