[REF] mail: rename notif_layout to email_layout_xmlid on message model

Purpose is to make field use more obvious by correctly stating in the
name it should contain an xml id to a qweb layout used for email
notifications. This renaming is propagated through various calls and
addons.

Related to task 1943901
Linked to PR #32404
This commit is contained in:
Xavier-Do
2019-05-29 13:34:32 +00:00
committed by Thibault Delavallée
parent 581a74143e
commit 2fcb3c658d
16 changed files with 23 additions and 25 deletions
+3 -3
View File
@@ -567,7 +567,7 @@ class Challenge(models.Model):
body=body_html,
partner_ids=challenge.mapped('user_ids.partner_id.id'),
subtype='mail.mt_comment',
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
if challenge.report_message_group_id:
challenge.report_message_group_id.message_post(
@@ -591,13 +591,13 @@ class Challenge(models.Model):
body=body_html,
partner_ids=[user.partner_id.id],
subtype='mail.mt_comment',
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
if challenge.report_message_group_id:
challenge.report_message_group_id.message_post(
body=body_html,
subtype='mail.mt_comment',
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
return challenge.write({'last_report_date': fields.Date.today()})
+1 -1
View File
@@ -226,7 +226,7 @@ class Goal(models.Model):
body=body_html,
partner_ids=[self.user_id.partner_id.id],
subtype='mail.mt_comment',
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
return {'to_update': True}
+1 -1
View File
@@ -532,7 +532,7 @@ class HrExpense(models.Model):
subject='Re: %s' % msg_dict.get('subject', ''),
body=body,
subtype_id=self.env.ref('mail.mt_note').id,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
else:
self.env['mail.mail'].create({
@@ -353,7 +353,7 @@ class Applicant(models.Model):
res['stage_id'] = (applicant.stage_id.template_id, {
'auto_delete_message': True,
'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'),
'notif_layout': 'mail.mail_notification_light'
'email_layout_xmlid': 'mail.mail_notification_light'
})
return res
+1 -1
View File
@@ -394,7 +394,7 @@ class MailActivity(models.Model):
subject=_('%s: %s assigned to you') % (activity.res_name, activity.summary or activity.activity_type_id.name),
record_name=activity.res_name,
model_description=model_description,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
@api.multi
+1 -1
View File
@@ -124,7 +124,7 @@ class Message(models.Model):
moderator_id = fields.Many2one('res.users', string="Moderated By", index=True)
need_moderation = fields.Boolean('Need moderation', compute='_compute_need_moderation', search='_search_need_moderation')
#keep notification layout informations to be able to generate mail again
layout = fields.Char('Layout', copy=False) # xml id of layout
email_layout_xmlid = fields.Char('Layout', copy=False, oldname='layout') # xml id of layout
add_sign = fields.Boolean(default=True)
@api.multi
+5 -7
View File
@@ -1795,7 +1795,7 @@ class MailThread(models.AbstractModel):
record.message_post_with_template(False, **kwargs)
@api.multi
def message_post_with_template(self, template_id, **kwargs):
def message_post_with_template(self, template_id, email_layout_xmlid=None, **kwargs):
""" Helper method to send a mail with a template
:param template_id : the id of the template to render to create the body of the message
:param **kwargs : parameter to create a mail.compose.message woaerd (which inherit from mail.message)
@@ -1807,7 +1807,6 @@ class MailThread(models.AbstractModel):
kwargs['message_type'] = 'notification'
res_id = kwargs.get('res_id', self.ids and self.ids[0] or 0)
res_ids = kwargs.get('res_id') and [kwargs['res_id']] or self.ids
notif_layout = kwargs.pop('notif_layout', None)
# Create the composer
composer = self.env['mail.compose.message'].with_context(
@@ -1818,7 +1817,7 @@ class MailThread(models.AbstractModel):
default_model=kwargs.get('model', self._name),
default_res_id=res_id,
default_template_id=template_id,
custom_layout=notif_layout,
custom_layout=email_layout_xmlid,
).create(kwargs)
# Simulate the onchange (like trigger in form the view) only
# when having a template in single-email mode
@@ -1922,8 +1921,6 @@ class MailThread(models.AbstractModel):
def _message_create(self, values):
create_values = dict(values)
if 'notif_layout' in create_values:
create_values['layout'] = create_values.pop('notif_layout')
# Avoid warnings about non-existing fields
for x in ('from', 'to', 'cc', 'canned_response_ids'):
create_values.pop(x, None)
@@ -1931,6 +1928,7 @@ class MailThread(models.AbstractModel):
create_values['channel_ids'] = [(4, cid) for cid in create_values.get('channel_ids', [])]
return self.env['mail.message'].create(create_values)
# ------------------------------------------------------
# Notification API
# ------------------------------------------------------
@@ -2010,7 +2008,7 @@ class MailThread(models.AbstractModel):
base_template_ctx = self._notify_prepare_template_context(message, msg_vals, model_description=model_description)
template_xmlid = message.layout if message.layout else 'mail.message_notification_email'
template_xmlid = message.email_layout_xmlid if message.email_layout_xmlid else 'mail.message_notification_email'
try:
base_template = self.env.ref(template_xmlid, raise_if_not_found=True).with_context(lang=base_template_ctx['lang'])
except ValueError:
@@ -2605,7 +2603,7 @@ class MailThread(models.AbstractModel):
body=assignation_msg,
partner_ids=partner_ids,
record_name=record.display_name,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
model_description=model_description,
)
+1 -1
View File
@@ -274,7 +274,7 @@ class MailComposer(models.TransientModel):
post_params = dict(
message_type=wizard.message_type,
subtype_id=subtype_id,
notif_layout=notif_layout,
email_layout_xmlid=notif_layout,
add_sign=not bool(wizard.template_id),
mail_auto_delete=wizard.template_id.auto_delete if wizard.template_id else False,
model_description=model_description)
+2 -2
View File
@@ -58,7 +58,7 @@ class PortalShare(models.TransientModel):
'share_link': share_link},
subject=_("You are invited to access %s" % active_record.display_name),
subtype_id=note.id,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
partner_ids=[(6, 0, partner.ids)])
# when partner not user send individual mail with signup token
for partner in self.partner_ids - partner_ids:
@@ -70,6 +70,6 @@ class PortalShare(models.TransientModel):
'share_link': share_link},
subject=_("You are invited to access %s" % active_record.display_name),
subtype_id=note.id,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
partner_ids=[(6, 0, partner.ids)])
return {'type': 'ir.actions.act_window_close'}
+1 -1
View File
@@ -792,7 +792,7 @@ class Task(models.Model):
res['stage_id'] = (test_task.stage_id.mail_template_id, {
'auto_delete_message': True,
'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'),
'notif_layout': 'mail.mail_notification_light'
'email_layout_xmlid': 'mail.mail_notification_light'
})
return res
+1 -1
View File
@@ -160,7 +160,7 @@ class RatingMixin(models.AbstractModel):
record.message_post_with_template(
template.id,
composition_mode=composition_mode,
notif_layout=notif_layout if notif_layout is not None else 'mail.mail_notification_light',
email_layout_xmlid=notif_layout if notif_layout is not None else 'mail.mail_notification_light',
subtype_id=subtype_id
)
+1 -1
View File
@@ -106,7 +106,7 @@ class PaymentTransaction(models.Model):
for trans in self.filtered(lambda t: t.sale_order_ids):
trans = trans.with_context(ctx_company)
for invoice in trans.invoice_ids:
invoice.message_post_with_template(int(default_template), notif_layout="mail.mail_notification_paynow")
invoice.message_post_with_template(int(default_template), email_layout_xmlid="mail.mail_notification_paynow")
return res
@api.multi
+1 -1
View File
@@ -667,7 +667,7 @@ class SaleOrder(models.Model):
template_id = self._find_mail_template(force_confirmation_template=True)
if template_id:
for order in self:
order.with_context(force_send=True).message_post_with_template(template_id, composition_mode='comment', notif_layout="mail.mail_notification_paynow")
order.with_context(force_send=True).message_post_with_template(template_id, composition_mode='comment', email_layout_xmlid="mail.mail_notification_paynow")
@api.multi
def action_done(self):
+1 -1
View File
@@ -246,7 +246,7 @@ class SaleOrder(models.Model):
self.message_post_with_template(
template.id, composition_mode='comment',
model='sale.coupon', res_id=coupon.id,
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
def _get_applicable_programs(self):
@@ -142,7 +142,7 @@ class Track(models.Model):
'composition_mode': 'comment',
'auto_delete_message': True,
'subtype_id': self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note'),
'notif_layout': 'mail.mail_notification_light'
'email_layout_xmlid': 'mail.mail_notification_light'
})
return res
+1 -1
View File
@@ -361,7 +361,7 @@ class Slide(models.Model):
subject=subject,
body=html_body,
subtype='website_slides.mt_channel_slide_published',
notif_layout='mail.mail_notification_light',
email_layout_xmlid='mail.mail_notification_light',
)
return True