[FIX] mail: action send mail no default_type

Have a send email automated action on invoices upon validation (write)

Go onto the credit notes, create one, and validate

Before this commit, at the creation of the attachment (the invoice pdf), there was a traceback
because default_type was in the context containing 'out_refund'
And that attachments also have a field 'type'
So the default_get of the latter got a value that wasn't correct for its field

After this commit, we clean the context of the default_type context key since it
is irrelevant beyond that point

OPW 1868638

closes #26621
This commit is contained in:
Lucas Perais (lpe)
2018-09-11 09:35:44 +02:00
parent f5e145d2b9
commit 816f386161
+5 -1
View File
@@ -48,7 +48,11 @@ class ServerActions(models.Model):
# TDE CLEANME: when going to new api with server action, remove action
if not action.template_id or not self._context.get('active_id'):
return False
action.template_id.send_mail(self._context.get('active_id'), force_send=False, raise_exception=False)
# Clean context from default_type to avoid making attachment
# with wrong values in subsequent operations
cleaned_ctx = dict(self.env.context)
cleaned_ctx.pop('default_type', None)
action.template_id.with_context(cleaned_ctx).send_mail(self._context.get('active_id'), force_send=False, raise_exception=False)
return False
@api.model