From 5d4f139df29fc30f38ee1b35c94d72e0e69bd8a7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 12 Feb 2014 12:39:24 +0100 Subject: [PATCH] [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 --- addons/base_action_rule/base_action_rule.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 3d45407cb0e..37c4980528e 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -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