diff --git a/addons/email_template/ir_actions.py b/addons/email_template/ir_actions.py index 3e7d2c1c67a..5304b6f6cbc 100644 --- a/addons/email_template/ir_actions.py +++ b/addons/email_template/ir_actions.py @@ -79,5 +79,18 @@ class actions_server(osv.Model): force_send=False, raise_exception=False, context=context) return False + def _get_eval_context(self, cr, uid, action, context=None): + """ Override the method giving the evaluation context but also the + context used in all subsequent calls. Add the mail_notify_force_send + key set to False in the context. This way all notification emails linked + to the currently executed action will be set in the queue instead of + sent directly. This will avoid possible break in transactions. """ + eval_context = super(actions_server, self)._get_eval_context(cr, uid, action, context=context) + # re-dictify, because eval_context['context'] is a frozendict + ctx = dict(eval_context.get('context', {})) + ctx['mail_notify_force_send'] = False + eval_context['context'] = ctx + return eval_context + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: