[FIX] base_action_rule: attempt to reuse creator language when evaluating action filters

Some filters needs to be evaluated with the same
language as their author, e.g. when searching on
translatable field values. When a time-based
action is processed by the scheduled task,
we should thus attempt to reuse the same
language as the author of the corresponding
filter.

bzr revid: odo@openerp.com-20140212113924-77sh4oj6dl2qwqka
This commit is contained in:
Olivier Dony 2014-02-12 12:39:24 +01:00
parent b6e708c1be
commit 5d4f139df2
1 changed files with 7 additions and 0 deletions

View File

@ -242,6 +242,13 @@ class base_action_rule(osv.osv):
if action.filter_id:
domain = eval(action.filter_id.domain)
ctx.update(eval(action.filter_id.context))
if 'lang' not in ctx:
# Filters might be language-sensitive, attempt to reuse creator lang
# as we are usually running this as super-user in background
[filter_meta] = action.filter_id.perm_read()
user_id = filter_meta['write_uid'] and filter_meta['write_uid'][0] or \
filter_meta['create_uid'][0]
ctx['lang'] = self.pool['res.users'].browse(cr, uid, user_id).lang
record_ids = model.search(cr, uid, domain, context=ctx)
# determine when action should occur for the records