Open fernandahf opened 1 week ago
FYI @moylop260
IMHO it could be apply without patches but inherit
I mean,
You can use
def _message_post_helper(res_model, res_id, message, token='', _hash=False, pid=False, nosubscribe=True, **kw):
if request.env.context.get("skip_partner_ids") and kw.get("partner_ids"):
kw.pop("partner_ids")
if request.env.context.get("force_only_note"):
kw["message_type"] = "notification"
kw["subtype_xmlid"] = "mail.mt_note"
return super()._message_post_helper(res_model, res_id, message, token=token, _hash=_hash, pid=pid, nosubscribe=nosubscribe, **kw)
@moylop260
The method is not inheritable because it's not under a class:
I got it
What about monkey patch using hooks.py
?
I mean,
from odoo.addons.portal.controllers import mail
_original_message_post_helper = mail._message_post_helper
def _custom_message_post_helper(self, res_model, res_id, message, token='', _hash=False, pid=False, nosubscribe=True, **kw):
if request.env.context.get("skip_partner_ids") and kw.get("partner_ids"):
kw.pop("partner_ids")
if request.env.context.get("force_only_note"):
kw["message_type"] = "notification"
kw["subtype_xmlid"] = "mail.mt_note"
return _original_message_post_helper(self, res_model, res_id, message, token=token, _hash=_hash, pid=pid, nosubscribe=nosubscribe, **kw)
mail._message_post_helper = _custom_message_post_helper
When an order is reviewed by the partner and when an order is cancelled from the portal, a notification is sent to the followers of the order, which allows to configure that from a context.
Related: #https://gitlab.com/ircanada/ircodoo/-/issues/2901
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr