[MERGE] base.action.rule: better handle non-ASCII data

Also fixes the `regex_history` expression
that should search on the `subject` field
now (it was renamed in 6.1).

lp bug: https://launchpad.net/bugs/921442 fixed

bzr revid: odo@openerp.com-20120316144251-ks16hvvfgh2hiduk
This commit is contained in:
Olivier Dony 2012-03-16 15:42:51 +01:00
commit 61ee0dc8ee
2 changed files with 6 additions and 4 deletions

View File

@ -24,6 +24,7 @@ from tools.translate import _
from datetime import datetime
from datetime import timedelta
from tools.safe_eval import safe_eval
from tools import ustr
import pooler
import re
import time
@ -369,8 +370,8 @@ the rule to mark CC(mail to any other person defined in actions)."),
reg_name = action.regex_name
result_name = True
if reg_name:
ptrn = re.compile(str(reg_name))
_result = ptrn.search(str(obj.name))
ptrn = re.compile(ustr(reg_name))
_result = ptrn.search(ustr(obj.name))
if not _result:
result_name = False
regex_n = not reg_name or result_name

View File

@ -23,6 +23,7 @@ import re
import tools
from tools.translate import _
from tools import ustr
from osv import fields
from osv import osv
@ -73,9 +74,9 @@ class base_action_rule(osv.osv):
regex = action.regex_history
if regex:
res = False
ptrn = re.compile(str(regex))
ptrn = re.compile(ustr(regex))
for history in obj.message_ids:
_result = ptrn.search(str(history.name))
_result = ptrn.search(ustr(history.subject))
if _result:
res = True
break