summaryrefslogtreecommitdiff
path: root/addons/mail/models
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2019-04-12 13:16:48 +0000
committerThibault Delavallée <tde@odoo.com>2019-05-29 13:34:32 +0000
commit2fcb3c658df3e504b92ff9b5a805d150cfa7effd (patch)
tree211bc53b2593e3f165ea7831187ad96965e66538 /addons/mail/models
parent581a74143e9d215654b1988e2480c6516a3a4887 (diff)
[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
Diffstat (limited to 'addons/mail/models')
-rw-r--r--addons/mail/models/mail_activity.py2
-rw-r--r--addons/mail/models/mail_message.py2
-rw-r--r--addons/mail/models/mail_thread.py12
3 files changed, 7 insertions, 9 deletions
diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py
index 6b9ce7aacf2..3dee568ca10 100644
--- a/addons/mail/models/mail_activity.py
+++ b/addons/mail/models/mail_activity.py
@@ -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
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py
index 5db3abe850f..95fc750066b 100644
--- a/addons/mail/models/mail_message.py
+++ b/addons/mail/models/mail_message.py
@@ -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
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index b17937f1734..7f29e0d13c4 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -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,
)