summaryrefslogtreecommitdiff
path: root/addons/mail/models
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2020-06-04 12:39:11 +0200
committerMartin Trigaux <mat@odoo.com>2020-06-18 13:03:34 +0200
commitba244cef01132347df4d2d9553ea3105ba13a938 (patch)
tree20cdb55afb6b9f700bfe2844a90ca8de0050c941 /addons/mail/models
parent3c3b88f6768e31417263b3828a874ca204e29514 (diff)
[IMP] *: replace to new _() syntax
Using a few regex like \((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\) ($1, $3)) Old syntax is still compatible but starts the migration to the new syntax that catches error.
Diffstat (limited to 'addons/mail/models')
-rw-r--r--addons/mail/models/mail_blacklist.py2
-rw-r--r--addons/mail/models/mail_channel.py4
-rw-r--r--addons/mail/models/mail_render_mixin.py2
-rw-r--r--addons/mail/models/mail_template.py6
-rw-r--r--addons/mail/models/mail_thread.py14
-rw-r--r--addons/mail/models/mail_thread_blacklist.py4
6 files changed, 16 insertions, 16 deletions
diff --git a/addons/mail/models/mail_blacklist.py b/addons/mail/models/mail_blacklist.py
index cbe5cc6693b..059c6e9e629 100644
--- a/addons/mail/models/mail_blacklist.py
+++ b/addons/mail/models/mail_blacklist.py
@@ -28,7 +28,7 @@ class MailBlackList(models.Model):
for value in values:
email = tools.email_normalize(value.get('email'))
if not email:
- raise UserError(_('Invalid email address %r') % value['email'])
+ raise UserError(_('Invalid email address %r', value['email']))
if email in all_emails:
continue
all_emails.append(email)
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 1d7c35fabc9..e2ea498ef0e 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -427,7 +427,7 @@ class Channel(models.Model):
'email_from': company.catchall_formatted or company.email_formatted,
'author_id': self.env.user.partner_id.id,
'body_html': view._render({'channel': self, 'partner': partner}, engine='ir.qweb', minimal_qcontext=True),
- 'subject': _("Guidelines of channel %s") % self.name,
+ 'subject': _("Guidelines of channel %s", self.name),
'recipient_ids': [(4, partner.id)]
}
mail = self.env['mail.mail'].sudo().create(create_values)
@@ -976,7 +976,7 @@ class Channel(models.Model):
def _execute_command_help(self, **kwargs):
partner = self.env.user.partner_id
if self.channel_type == 'channel':
- msg = _("You are in channel <b>#%s</b>.") % self.name
+ msg = _("You are in channel <b>#%s</b>.", self.name)
if self.public == 'private':
msg += _(" This channel is private. People must be invited to join it.")
else:
diff --git a/addons/mail/models/mail_render_mixin.py b/addons/mail/models/mail_render_mixin.py
index ddd32659a03..79b66e55f8b 100644
--- a/addons/mail/models/mail_render_mixin.py
+++ b/addons/mail/models/mail_render_mixin.py
@@ -316,7 +316,7 @@ class MailRenderMixin(models.AbstractModel):
render_result = template.render(variables)
except Exception as e:
_logger.info("Failed to render template : %s" % e, exc_info=True)
- raise UserError(_("Failed to render template : %s") % e)
+ raise UserError(_("Failed to render template : %s", e))
if render_result == u"False":
render_result = u""
results[record.id] = render_result
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index f8f90aea5fd..92783104b65 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -74,7 +74,7 @@ class MailTemplate(models.Model):
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
default = dict(default or {},
- name=_("%s (copy)") % self.name)
+ name=_("%s (copy)", self.name))
return super(MailTemplate, self).copy(default=default)
def unlink_action(self):
@@ -88,7 +88,7 @@ class MailTemplate(models.Model):
view = self.env.ref('mail.email_compose_message_wizard_form')
for template in self:
- button_name = _('Send Mail (%s)') % template.name
+ button_name = _('Send Mail (%s)', template.name)
action = ActWindow.create({
'name': button_name,
'type': 'ir.actions.act_window',
@@ -200,7 +200,7 @@ class MailTemplate(models.Model):
else:
res = report._render([res_id])
if not res:
- raise UserError(_('Unsupported report type %s found.') % report.report_type)
+ raise UserError(_('Unsupported report type %s found.', report.report_type))
result, format = res
# TODO in trunk, change return format to binary to match message_post expected format
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index ee16931f25e..3f8818bc386 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -544,7 +544,7 @@ class MailThread(models.AbstractModel):
"""
self.ensure_one()
doc_name = self.env['ir.model']._get(self._name).name
- return _('%s created') % doc_name
+ return _('%s created', doc_name)
def _track_subtype(self, init_values):
""" Give the subtypes triggered by the changes on the record according
@@ -671,7 +671,7 @@ class MailThread(models.AbstractModel):
def _routing_warn(self, error_message, message_id, route, raise_exception=True):
""" Tools method used in _routing_check_route: whether to log a warning or raise an error """
- short_message = _("Mailbox unavailable - %s") % error_message
+ short_message = _("Mailbox unavailable - %s", error_message)
full_message = ('Routing mail with Message-Id %s: route %s: %s' %
(message_id, route, error_message))
_logger.info(full_message)
@@ -791,7 +791,7 @@ class MailThread(models.AbstractModel):
self._routing_warn(_('target model unspecified'), message_id, route, raise_exception)
return ()
elif model not in self.env:
- self._routing_warn(_('unknown target model %s') % model, message_id, route, raise_exception)
+ self._routing_warn(_('unknown target model %s', model), message_id, route, raise_exception)
return ()
record_set = self.env[model].browse(thread_id) if thread_id else self.env[model]
@@ -801,12 +801,12 @@ class MailThread(models.AbstractModel):
self._routing_warn(_('reply to missing document (%s,%s), fall back on document creation') % (model, thread_id), message_id, route, False)
thread_id = None
elif not hasattr(record_set, 'message_update'):
- self._routing_warn(_('reply to model %s that does not accept document update, fall back on document creation') % model, message_id, route, False)
+ self._routing_warn(_('reply to model %s that does not accept document update, fall back on document creation', model), message_id, route, False)
thread_id = None
# New Document: check model accepts the mailgateway
if not thread_id and model and not hasattr(record_set, 'message_new'):
- self._routing_warn(_('model %s does not accept document creation') % model, message_id, route, raise_exception)
+ self._routing_warn(_('model %s does not accept document creation', model), message_id, route, raise_exception)
return ()
# Update message author. We do it now because we need it for aliases (contact settings)
@@ -2595,7 +2595,7 @@ class MailThread(models.AbstractModel):
access_link = self._notify_get_action_link('view')
if model_name:
- view_title = _('View %s') % model_name
+ view_title = _('View %s', model_name)
else:
view_title = _('View')
@@ -2859,7 +2859,7 @@ class MailThread(models.AbstractModel):
assignation_msg = view._render(values, engine='ir.qweb', minimal_qcontext=True)
assignation_msg = self.env['mail.render.mixin']._replace_local_links(assignation_msg)
record.message_notify(
- subject=_('You have been assigned to %s') % record.display_name,
+ subject=_('You have been assigned to %s', record.display_name),
body=assignation_msg,
partner_ids=partner_ids,
record_name=record.display_name,
diff --git a/addons/mail/models/mail_thread_blacklist.py b/addons/mail/models/mail_thread_blacklist.py
index 00f6bb95518..f17302f360e 100644
--- a/addons/mail/models/mail_thread_blacklist.py
+++ b/addons/mail/models/mail_thread_blacklist.py
@@ -93,9 +93,9 @@ class MailBlackListMixin(models.AbstractModel):
def _assert_primary_email(self):
if not hasattr(self, "_primary_email") or not isinstance(self._primary_email, str):
- raise UserError(_('Invalid primary email field on model %s') % self._name)
+ raise UserError(_('Invalid primary email field on model %s', self._name))
if self._primary_email not in self._fields or self._fields[self._primary_email].type != 'char':
- raise UserError(_('Invalid primary email field on model %s') % self._name)
+ raise UserError(_('Invalid primary email field on model %s', self._name))
def _message_receive_bounce(self, email, partner):
""" Override of mail.thread generic method. Purpose is to increment the