[IMP] account, project, purchase, sale, {test_}mail: improves mail re-usability
"mail_notification_paynow" mail template layout has been renamed to "mail_notification_responsible_signature_layout" as it now only differ by the signature. It allows to use it more widely. Task-2801600 Part-of: odoo/odoo#88466
This commit is contained in:
@@ -3063,7 +3063,7 @@ class AccountMove(models.Model):
|
||||
'res_model': 'account.invoice.send',
|
||||
'view_mode': 'form',
|
||||
'context': {
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_paynow',
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_layout_with_responsible_signature',
|
||||
'default_template_id': self.env.ref(self._get_mail_template()).id,
|
||||
'mark_invoice_as_sent': True,
|
||||
'active_model': 'account.move',
|
||||
@@ -3099,7 +3099,7 @@ class AccountMove(models.Model):
|
||||
default_template_id=template and template.id or False,
|
||||
default_composition_mode='comment',
|
||||
mark_invoice_as_sent=True,
|
||||
default_email_layout_xmlid="mail.mail_notification_paynow",
|
||||
default_email_layout_xmlid="mail.mail_notification_layout_with_responsible_signature",
|
||||
model_description=self.with_context(lang=lang).type_name,
|
||||
force_email=True,
|
||||
)
|
||||
|
||||
@@ -287,7 +287,8 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="mail_notification_paynow" name="Mail: Pay Now mail notification template"
|
||||
<template id="mail_notification_layout_with_responsible_signature"
|
||||
name="Mail: mail notification layout with responsible signature (user_id of the record)"
|
||||
inherit_id="mail.mail_notification_layout" primary="True">
|
||||
<xpath expr="//t[hasclass('o_signature')]" position="replace">
|
||||
<t t-if="email_add_signature and 'user_id' in record and record.user_id and not record.env.user._is_superuser() and not is_html_empty(record.user_id.sudo().signature)">
|
||||
|
||||
@@ -423,7 +423,7 @@ class PurchaseOrder(models.Model):
|
||||
'default_use_template': bool(template_id),
|
||||
'default_template_id': template_id,
|
||||
'default_composition_mode': 'comment',
|
||||
'default_email_layout_xmlid': "mail.mail_notification_paynow",
|
||||
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||
'force_email': True,
|
||||
'mark_rfq_as_sent': True,
|
||||
})
|
||||
@@ -747,7 +747,7 @@ class PurchaseOrder(models.Model):
|
||||
if send_single:
|
||||
return order._send_reminder_open_composer(template.id)
|
||||
else:
|
||||
order.with_context(is_reminder=True).message_post_with_template(template.id, email_layout_xmlid="mail.mail_notification_paynow", composition_mode='comment')
|
||||
order.with_context(is_reminder=True).message_post_with_template(template.id, email_layout_xmlid="mail.mail_notification_layout_with_responsible_signature", composition_mode='comment')
|
||||
|
||||
def send_reminder_preview(self):
|
||||
self.ensure_one()
|
||||
@@ -760,7 +760,7 @@ class PurchaseOrder(models.Model):
|
||||
self.id,
|
||||
force_send=True,
|
||||
raise_exception=False,
|
||||
email_layout_xmlid="mail.mail_notification_paynow",
|
||||
email_layout_xmlid="mail.mail_notification_layout_with_responsible_signature",
|
||||
email_values={'email_to': self.env.user.email, 'recipient_ids': []},
|
||||
)
|
||||
return {'toast_message': escape(_("A sample email has been sent to %s.", self.env.user.email))}
|
||||
@@ -780,7 +780,7 @@ class PurchaseOrder(models.Model):
|
||||
'default_use_template': bool(template_id),
|
||||
'default_template_id': template_id,
|
||||
'default_composition_mode': 'comment',
|
||||
'default_email_layout_xmlid': "mail.mail_notification_paynow",
|
||||
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||
'force_email': True,
|
||||
'mark_rfq_as_sent': True,
|
||||
})
|
||||
|
||||
@@ -132,7 +132,7 @@ class PaymentTransaction(models.Model):
|
||||
for invoice in invoice_to_send.with_user(SUPERUSER_ID):
|
||||
invoice.message_post_with_template(
|
||||
int(template_id),
|
||||
email_layout_xmlid='mail.mail_notification_paynow',
|
||||
email_layout_xmlid='mail.mail_notification_layout_with_responsible_signature',
|
||||
)
|
||||
|
||||
def _cron_send_invoice(self):
|
||||
|
||||
@@ -94,7 +94,7 @@ class ResCompany(models.Model):
|
||||
message_composer = self.env['mail.compose.message'].with_context(
|
||||
default_use_template=bool(template),
|
||||
mark_so_as_sent=True,
|
||||
default_email_layout_xmlid='mail.mail_notification_paynow',
|
||||
default_email_layout_xmlid='mail.mail_notification_layout_with_responsible_signature',
|
||||
proforma=self.env.context.get('proforma', False),
|
||||
force_email=True, mail_notify_author=True
|
||||
).create({
|
||||
|
||||
@@ -728,7 +728,7 @@ class SaleOrder(models.Model):
|
||||
'default_template_id': mail_template.id if mail_template else None,
|
||||
'default_composition_mode': 'comment',
|
||||
'mark_so_as_sent': True,
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_paynow',
|
||||
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||
'proforma': self.env.context.get('proforma', False),
|
||||
'force_email': True,
|
||||
'model_description': self.with_context(lang=lang).type_name,
|
||||
@@ -837,7 +837,7 @@ class SaleOrder(models.Model):
|
||||
self.with_context(force_send=True).message_post_with_template(
|
||||
mail_template.id,
|
||||
composition_mode='comment',
|
||||
email_layout_xmlid='mail.mail_notification_paynow',
|
||||
email_layout_xmlid='mail.mail_notification_layout_with_responsible_signature',
|
||||
)
|
||||
|
||||
def action_done(self):
|
||||
@@ -873,7 +873,7 @@ class SaleOrder(models.Model):
|
||||
'default_template_id': template_id,
|
||||
'default_order_id': self.id,
|
||||
'mark_so_as_canceled': True,
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_paynow',
|
||||
'default_email_layout_xmlid': "mail.mail_notification_layout_with_responsible_signature",
|
||||
'model_description': self.with_context(lang=lang).type_name,
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -88,7 +88,8 @@ class TestMailNotifyAPI(TestMessagePostCommon):
|
||||
recipients_data = self._generate_notify_recipients(self.partner_1 + self.partner_2 + self.partner_employee)
|
||||
for email_xmlid in ['mail.message_notification_email',
|
||||
'mail.mail_notification_light',
|
||||
'mail.mail_notification_paynow']:
|
||||
'mail.mail_notification_layout',
|
||||
'mail.mail_notification_layout_with_responsible_signature']:
|
||||
test_message.sudo().notification_ids.unlink() # otherwise partner/message constraint fails
|
||||
test_message.write({'email_layout_xmlid': email_xmlid})
|
||||
with self.mock_mail_gateway():
|
||||
@@ -118,14 +119,14 @@ class TestMailNotifyAPI(TestMessagePostCommon):
|
||||
|
||||
signature = self.env.user.signature
|
||||
|
||||
template = self.env.ref('mail.mail_notification_paynow', raise_if_not_found=True).sudo()
|
||||
template = self.env.ref('mail.mail_notification_layout_with_responsible_signature', raise_if_not_found=True).sudo()
|
||||
self.assertIn("record.user_id.sudo().signature", template.arch)
|
||||
|
||||
with self.mock_mail_gateway():
|
||||
test_track.message_post(
|
||||
body="Test body",
|
||||
email_add_signature=True,
|
||||
email_layout_xmlid="mail.mail_notification_paynow",
|
||||
email_layout_xmlid="mail.mail_notification_layout_with_responsible_signature",
|
||||
mail_auto_delete=False,
|
||||
partner_ids=[self.partner_1.id, self.partner_2.id],
|
||||
)
|
||||
@@ -137,7 +138,7 @@ class TestMailNotifyAPI(TestMessagePostCommon):
|
||||
test_track.message_post(
|
||||
body="Test body",
|
||||
email_add_signature=False,
|
||||
email_layout_xmlid="mail.mail_notification_paynow",
|
||||
email_layout_xmlid="mail.mail_notification_layout_with_responsible_signature",
|
||||
mail_auto_delete=False,
|
||||
partner_ids=[self.partner_1.id, self.partner_2.id],
|
||||
)
|
||||
|
||||
@@ -345,7 +345,7 @@ class SaleOrder(models.Model):
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_composition_mode': 'mass_mail' if len(self.ids) > 1 else 'comment',
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_paynow',
|
||||
'default_email_layout_xmlid': 'mail.mail_notification_layout_with_responsible_signature',
|
||||
'default_res_id': self.ids[0],
|
||||
'default_model': 'sale.order',
|
||||
'default_use_template': bool(template_id),
|
||||
|
||||
Reference in New Issue
Block a user