[6-stable] action rule crashes when name in foreign language

Bug #926616 reported by Grzegorz Grzelak (OpenGLOBE.pl)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

I have checked it is the same in 6.0.3.

When you use system in country using extended character set (like in Poland) you will get lead name (subjects) with national character. Fe if leads are created automatically from incoming mail.

Try to create lead manually with subject "Urządzenie - oferta" (note character "ą"), Then if you wish to trigger some server action according to this subject and subject contains national characters you will get crash error like below.

Fixing suggestion in next entry.

Environment Information :
System : Windows-32bit-SP1
OS Name : nt
Operating System Release :
Operating System Version : 32bit
Operating System Architecture : 32bit
Operating System Locale : pl_PL.cp1250
Python Version : 2.5.2
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call
last):
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/netsvc.py", line
489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth,
params)
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/service/web_services.py",
line 599, in dispatch
    res = fn(db, uid, *params)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line
122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line
176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/lib/python2.6/dist-packages/openerp-server/osv/osv.py", line
167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/addons/crm/crm.py", line
413, in case_pending
    self._action(cr, uid, cases, 'pending')
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/addons/crm/crm.py", line
524, in _action
    return rule_obj._action(cr, uid, rule_ids, cases, scrit=scrit,
context=context)
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base_action_rule/base_action_rule.py",
line 454, in _action
    ok = self.do_check(cr, uid, action, obj, context=context)
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/addons/crm/crm_action_rule.py",
line 75, in do_check
    ok = super(base_action_rule, self).do_check(cr, uid, action, obj,
context=context)
  File
"/usr/local/lib/python2.6/dist-packages/openerp-server/addons/base_action_rule/base_action_rule.py",
line 360, in do_check
    _result = ptrn.search(str(obj.name))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0105' in position
5: ordinal not in range(128)

Revision history for this message
Grzegorz Grzelak (OpenGLOBE.pl) (grzegorz-og.pl) wrote :

I have found fix for that from bug #564486. So I tried changes in lines 359 and 360 as below and it works. At the beginning I added
from tools import ustr #gg change

359 ptrn = re.compile(ustr(reg_name)) #gg change
360 _result = ptrn.search(ustr(obj.name)) # gg change

Please add ustr in both lines as lead subject AND regular expression should accept foreign characters.

All the best
GG.

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.