block notification on msg import
This commit is contained in:
parent
2df5651f12
commit
bb5b211d9c
3 changed files with 37 additions and 15 deletions
|
|
@ -1,2 +1,3 @@
|
|||
from . import ir_attachment
|
||||
from . import mail_thread
|
||||
from . import res_config_settings
|
||||
|
|
|
|||
|
|
@ -435,11 +435,14 @@ class IrAttachment(models.Model):
|
|||
target_thread_id = self.res_id if self.res_model else False
|
||||
|
||||
# Process the email with forced model
|
||||
self.env['mail.thread'].with_context(
|
||||
mail_create_nosubscribe=True, # Don't auto-subscribe the sender
|
||||
mail_create_nolog=True, # Don't create log message
|
||||
default_model=target_model, # Force the model
|
||||
).message_process(
|
||||
context = {
|
||||
'default_model': target_model, # Force the model
|
||||
'mail_notify_force_send': False, # Don't force send notifications
|
||||
'mail_auto_subscribe_no_notify': True, # Prevent auto-subscription notifications
|
||||
'is_msg_import': True, # Flag to identify MSG import
|
||||
}
|
||||
|
||||
self.env['mail.thread'].with_context(**context).message_process(
|
||||
model=target_model,
|
||||
message=eml_content,
|
||||
custom_values=custom_values,
|
||||
|
|
@ -657,16 +660,11 @@ class IrAttachment(models.Model):
|
|||
|
||||
# Set context for message creation
|
||||
context = {
|
||||
"default_model": self.res_model,
|
||||
"default_res_id": self.res_id,
|
||||
"mail_create_nosubscribe": True,
|
||||
"mail_create_nolog": True,
|
||||
"mail_notify_force_send": False,
|
||||
"mail_create_force_model": self.res_model,
|
||||
"mail_thread_quote": False,
|
||||
"mail_create_skip_followers": True,
|
||||
"mail_auto_subscribe_no_notify": True, # Prevent auto-subscription notifications
|
||||
"no_auto_thread": True # Prevent automatic thread creation
|
||||
'default_model': self.res_model,
|
||||
'default_res_id': self.res_id,
|
||||
'mail_notify_force_send': False, # Don't force send notifications
|
||||
'mail_auto_subscribe_no_notify': True, # Prevent auto-subscription notifications
|
||||
'is_msg_import': True, # Flag to identify MSG import
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
|
|||
23
msg_attachments_to_mail_message/models/mail_thread.py
Normal file
23
msg_attachments_to_mail_message/models/mail_thread.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from odoo import models, api
|
||||
from odoo.tools import email_normalize
|
||||
|
||||
|
||||
class MailThread(models.AbstractModel):
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
def _notify_thread(self, message, msg_vals=False, **kwargs):
|
||||
"""Override _notify_thread to disable notifications for MSG file imports.
|
||||
|
||||
When processing a message that comes from an MSG file import, we want to
|
||||
disable all notifications to avoid sending automatic responses.
|
||||
|
||||
Returns:
|
||||
list: Empty list of recipients when is_msg_import is True, otherwise normal recipients data
|
||||
"""
|
||||
# Check if this is called from MSG processing
|
||||
if self.env.context.get('is_msg_import', False):
|
||||
# Return empty recipients list for MSG imports
|
||||
return []
|
||||
|
||||
return super()._notify_thread(message, msg_vals=msg_vals, **kwargs)
|
||||
Loading…
Reference in a new issue