From 9d7964a6b5bc6820fc7bf0a94d2498346c283fc4 Mon Sep 17 00:00:00 2001 From: Thomas Groutars Date: Mon, 23 Mar 2015 15:33:15 +0100 Subject: [PATCH] [IMP] Add old values in context of on write automated actions --- addons/base_action_rule/base_action_rule.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 105fd4004a9..87d8a5e094b 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -208,6 +208,11 @@ class base_action_rule(osv.osv): for action in actions: pre_ids[action] = action_model._filter(cr, uid, action, action.filter_pre_id, ids, domain=action.filter_pre_domain, context=context) + # read old values before the update + old_values = {} + for old_vals in self.read(cr, uid, ids, list(vals), context=context): + old_values[old_vals.pop('id')] = old_vals + # call original method write.origin(self, cr, uid, ids, vals, context=context, **kwargs) @@ -215,7 +220,7 @@ class base_action_rule(osv.osv): for action in actions: post_ids = action_model._filter(cr, uid, action, action.filter_id, pre_ids[action], domain=action.filter_domain, context=context) if post_ids: - action_model._process(cr, uid, action, post_ids, context=context) + action_model._process(cr, uid, action, post_ids, context=dict(context, old_values=old_values)) return True return write