[FIX] mail: server action: do not send directly email notifications

This is a backport of a fix in 9, revision 890f1302c7.
In this revision a context key is added wshen evaluating server actions.
Notification emails created during a server action will be set in the queue
and not send directly.
This commit is contained in:
Thibault Delavallée
2015-11-23 17:36:39 +01:00
parent e74c12ffe2
commit af6305722f
+13
View File
@@ -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: