[15.0][IMP] mail_post_defer: consider force_send context#1855
[15.0][IMP] mail_post_defer: consider force_send context#1855smorita7749 wants to merge 1 commit into
Conversation
|
Hi @yajo, |
|
Pre-commit error may be caused by #1856 |
| or kwargs.get("force_send", False) | ||
| ) | ||
| kwargs.setdefault("force_send", force_send) | ||
| if not force_send: |
There was a problem hiding this comment.
suggestion: instead of the above change, just add this:
| if not force_send: | |
| if not force_send or self.env.context.get("force_send"): |
Explanation: The context is already kept in sub-calls. We just need to honor the context if present, but we don't need to alter the kwarg.
There was a problem hiding this comment.
Thanks for the review!
I believe this change is necessary.
_notify_record_by_email reads context only for
mail_notify_force_send, not force_send:
force_send = self.env.context.get('mail_notify_force_send', force_send)
This PR reads force_send from context early so that
kwargs.setdefault propagates True to
_notify_record_by_email, and emails.send() is
actually called.
Please let me know if my understanding is correct.
There was a problem hiding this comment.
I suppose @yajo meant if not force_send and not self.env.context.get("force_send"):, but it still doesn't look like it would work in _notify_record_by_email, since the force_send kwarg would be set to False and would prevail. I think the approach of this PR is correct.
| or kwargs.get("force_send", False) | ||
| ) | ||
| kwargs.setdefault("force_send", force_send) | ||
| if not force_send: |
There was a problem hiding this comment.
I suppose @yajo meant if not force_send and not self.env.context.get("force_send"):, but it still doesn't look like it would work in _notify_record_by_email, since the force_send kwarg would be set to False and would prevail. I think the approach of this PR is correct.
Standard Odoo modules (e.g. sale.order) use with_context(force_send=True) to request immediate email delivery. However, mail_post_defer was not checking force_send in context, causing these emails to be deferred unexpectedly. This change adds the context check so that force_send=True in context is properly considered.
@qrtl QT6282