[FIX] various: respect mail_post_autofollow previous values when adding it
Purpose of this commit is to avoid forcing mail_post_autofollow to True when it is set to False. It eases inheritance and custom behavior. Task-2612911 PR odoo/odoo#60792
This commit is contained in:
committed by
Thibault Delavallée
parent
d3faed9d9f
commit
a87c89d4ab
@@ -317,7 +317,7 @@ class AccountMove(models.Model):
|
||||
def message_post(self, **kwargs):
|
||||
if self.env.context.get('l10n_ch_mark_isr_as_sent'):
|
||||
self.filtered(lambda inv: not inv.l10n_ch_isr_sent).write({'l10n_ch_isr_sent': True})
|
||||
return super(AccountMove, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
|
||||
return super(AccountMove, self.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True))).message_post(**kwargs)
|
||||
|
||||
def _get_invoice_reference_ch_invoice(self):
|
||||
""" This sets ISR reference number which is generated based on customer's `Bank Account` and set it as
|
||||
|
||||
@@ -1082,7 +1082,7 @@ class MailActivityMixin(models.AbstractModel):
|
||||
template = self.env['mail.template'].browse(template_id).exists()
|
||||
if not template:
|
||||
return False
|
||||
for record in self.with_context(mail_post_autofollow=True):
|
||||
for record in self.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True)):
|
||||
record.message_post_with_template(
|
||||
template_id,
|
||||
composition_mode='comment'
|
||||
|
||||
@@ -59,7 +59,7 @@ class PortalShare(models.TransientModel):
|
||||
saved_lang = self.env.lang
|
||||
self = self.with_context(lang=partner.lang)
|
||||
template = self.env.ref('portal.portal_share_template', False)
|
||||
active_record.with_context(mail_post_autofollow=True).message_post_with_view(template,
|
||||
active_record.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True)).message_post_with_view(template,
|
||||
values={'partner': partner, 'note': self.note, 'record': active_record,
|
||||
'share_link': share_link},
|
||||
subject=_("You are invited to access %s", active_record.display_name),
|
||||
@@ -75,7 +75,7 @@ class PortalShare(models.TransientModel):
|
||||
saved_lang = self.env.lang
|
||||
self = self.with_context(lang=partner.lang)
|
||||
template = self.env.ref('portal.portal_share_template', False)
|
||||
active_record.with_context(mail_post_autofollow=True).message_post_with_view(template,
|
||||
active_record.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True)).message_post_with_view(template,
|
||||
values={'partner': partner, 'note': self.note, 'record': active_record,
|
||||
'share_link': share_link},
|
||||
subject=_("You are invited to access %s", active_record.display_name),
|
||||
|
||||
@@ -406,7 +406,7 @@ class PurchaseOrder(models.Model):
|
||||
def message_post(self, **kwargs):
|
||||
if self.env.context.get('mark_rfq_as_sent'):
|
||||
self.filtered(lambda o: o.state == 'draft').write({'state': 'sent'})
|
||||
return super(PurchaseOrder, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
|
||||
return super(PurchaseOrder, self.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True))).message_post(**kwargs)
|
||||
|
||||
def print_quotation(self):
|
||||
self.write({'state': "sent"})
|
||||
|
||||
@@ -895,7 +895,7 @@ class SaleOrder(models.Model):
|
||||
def message_post(self, **kwargs):
|
||||
if self.env.context.get('mark_so_as_sent'):
|
||||
self.filtered(lambda o: o.state == 'draft').with_context(tracking_disable=True).write({'state': 'sent'})
|
||||
return super(SaleOrder, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
|
||||
return super(SaleOrder, self.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True))).message_post(**kwargs)
|
||||
|
||||
def _sms_get_number_fields(self):
|
||||
""" No phone or mobile field is available on sale model. Instead SMS will
|
||||
|
||||
@@ -16,5 +16,5 @@ class MailComposeMessage(models.TransientModel):
|
||||
('cart_recovery_email_sent', '=', False),
|
||||
('is_abandoned_cart', '=', True)
|
||||
]).write({'cart_recovery_email_sent': True})
|
||||
self = self.with_context(mail_post_autofollow=True)
|
||||
self = self.with_context(mail_post_autofollow=self.env.context.get('mail_post_autofollow', True))
|
||||
return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)
|
||||
|
||||
Reference in New Issue
Block a user