[IMP] mail, various: cleanup empty list help message overrides
Purpose is to cleanup code: stop using help parameter name (use help_message as help is a keyword), try to call super(), ... Task-2710804 (Mail: Clean MailThread Posting API) Prepares Task-36879 (Mail: Support MultiCompany Aliases) Part-of: odoo/odoo#105992
This commit is contained in:
@@ -1234,13 +1234,13 @@ class Lead(models.Model):
|
||||
}
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
""" This method returns the action helpers for the leads. If help is already provided
|
||||
on the action, the same is returned. Otherwise, we build the help message which
|
||||
contains the alias responsible for creating the lead (if available) and return it.
|
||||
"""
|
||||
if not is_html_empty(help):
|
||||
return help
|
||||
if not is_html_empty(help_message):
|
||||
return help_message
|
||||
|
||||
help_title, sub_title = "", ""
|
||||
if self._context.get('default_type') == 'lead':
|
||||
@@ -1258,7 +1258,9 @@ class Lead(models.Model):
|
||||
email = '%s@%s' % (alias_record.alias_name, alias_record.alias_domain)
|
||||
email_link = "<b><a href='mailto:%s'>%s</a></b>" % (email, email)
|
||||
sub_title = _('Use the top left <i>Create</i> button, or send an email to %s to test the email gateway.') % (email_link)
|
||||
return '<p class="o_view_nocontent_smiling_face">%s</p><p class="oe_view_nocontent_alias">%s</p>' % (help_title, sub_title)
|
||||
return super().get_empty_list_help(
|
||||
f'<p class="o_view_nocontent_smiling_face">{help_title}</p><p class="oe_view_nocontent_alias">{sub_title}</p>'
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# BUSINESS
|
||||
|
||||
@@ -6,6 +6,7 @@ import logging
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.addons.iap.tools import iap_tools
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import is_html_empty
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -185,10 +186,15 @@ class CRMLeadMiningRequest(models.Model):
|
||||
self.company_size_max = self.company_size_min
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help_string):
|
||||
def get_empty_list_help(self, help_message):
|
||||
if not is_html_empty(help_message):
|
||||
return help_message
|
||||
|
||||
help_title = _('Create a Lead Mining Request')
|
||||
sub_title = _('Generate new leads based on their country, industry, size, etc.')
|
||||
return '<p class="o_view_nocontent_smiling_face">%s</p><p class="oe_view_nocontent_alias">%s</p>' % (help_title, sub_title)
|
||||
return super().get_empty_list_help(
|
||||
f'<p class="o_view_nocontent_smiling_face">{help_title}</p><p class="oe_view_nocontent_alias">{sub_title}</p>'
|
||||
)
|
||||
|
||||
def _prepare_iap_payload(self):
|
||||
"""
|
||||
|
||||
@@ -434,7 +434,7 @@ class Applicant(models.Model):
|
||||
self._update_employee_from_applicant()
|
||||
return res
|
||||
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
if 'active_id' in self.env.context and self.env.context.get('active_model') == 'hr.job':
|
||||
alias_id = self.env['hr.job'].browse(self.env.context['active_id']).alias_id
|
||||
else:
|
||||
@@ -453,9 +453,9 @@ class Applicant(models.Model):
|
||||
email = alias_id.display_name
|
||||
email_link = "<a href='mailto:%s'>%s</a>" % (email, email)
|
||||
nocontent_values['email_link'] = email_link
|
||||
nocontent_body += """<p class="o_copy_paste_email">%(email_link)s</p>"""
|
||||
nocontent_body += """<p class="o_copy_paste_email oe_view_nocontent_alias">%(email_link)s</p>"""
|
||||
|
||||
return nocontent_body % nocontent_values
|
||||
return super().get_empty_list_help(nocontent_body % nocontent_values)
|
||||
|
||||
@api.model
|
||||
def get_view(self, view_id=None, view_type='form', **options):
|
||||
|
||||
@@ -338,14 +338,14 @@ class MailThread(models.AbstractModel):
|
||||
return super(MailThread, self.with_context(mail_notrack=True)).copy_data(default=default)
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
""" Override of BaseModel.get_empty_list_help() to generate an help message
|
||||
that adds alias information. """
|
||||
model = self._context.get('empty_list_help_model')
|
||||
res_id = self._context.get('empty_list_help_id')
|
||||
catchall_domain = self.env['ir.config_parameter'].sudo().get_param("mail.catchall.domain")
|
||||
document_name = self._context.get('empty_list_help_document_name', _('document'))
|
||||
nothing_here = not help
|
||||
nothing_here = is_html_empty(help_message)
|
||||
alias = None
|
||||
|
||||
if catchall_domain and model and res_id: # specific res_id -> find its alias (i.e. section_id specified)
|
||||
@@ -369,28 +369,28 @@ class MailThread(models.AbstractModel):
|
||||
if alias:
|
||||
email_link = "<a href='mailto:%(email)s'>%(email)s</a>" % {'email': alias.display_name}
|
||||
if nothing_here:
|
||||
return "<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % {
|
||||
return super().get_empty_list_help("<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % {
|
||||
'dyn_help': _("Add a new %(document)s or send an email to %(email_link)s",
|
||||
document=document_name,
|
||||
email_link=email_link,
|
||||
)
|
||||
}
|
||||
})
|
||||
# do not add alias two times if it was added previously
|
||||
if "oe_view_nocontent_alias" not in help:
|
||||
return "%(static_help)s<p class='oe_view_nocontent_alias'>%(dyn_help)s</p>" % {
|
||||
'static_help': help,
|
||||
if "oe_view_nocontent_alias" not in help_message:
|
||||
return super().get_empty_list_help("%(static_help)s<p class='oe_view_nocontent_alias'>%(dyn_help)s</p>" % {
|
||||
'static_help': help_message,
|
||||
'dyn_help': _("Create new %(document)s by sending an email to %(email_link)s",
|
||||
document=document_name,
|
||||
email_link=email_link,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
if nothing_here:
|
||||
return "<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % {
|
||||
return super().get_empty_list_help("<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % {
|
||||
'dyn_help': _("Create new %(document)s", document=document_name),
|
||||
}
|
||||
})
|
||||
|
||||
return help
|
||||
return super().get_empty_list_help(help_message)
|
||||
|
||||
# ------------------------------------------------------
|
||||
# MODELS / CRUD HELPERS
|
||||
|
||||
@@ -1901,11 +1901,11 @@ class MrpProduction(models.Model):
|
||||
return action
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
self = self.with_context(
|
||||
empty_list_help_document_name=_("manufacturing order"),
|
||||
)
|
||||
return super(MrpProduction, self).get_empty_list_help(help)
|
||||
return super(MrpProduction, self).get_empty_list_help(help_message)
|
||||
|
||||
def _log_downside_manufactured_quantity(self, moves_modification, cancel=False):
|
||||
|
||||
|
||||
@@ -644,11 +644,11 @@ class ProductProduct(models.Model):
|
||||
return prices
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
self = self.with_context(
|
||||
empty_list_help_document_name=_("product"),
|
||||
)
|
||||
return super(ProductProduct, self).get_empty_list_help(help)
|
||||
return super(ProductProduct, self).get_empty_list_help(help_message)
|
||||
|
||||
def get_product_multiline_description_sale(self):
|
||||
""" Compute a multiline description of this product, in the context of sales
|
||||
|
||||
@@ -1283,11 +1283,11 @@ class ProductTemplate(models.Model):
|
||||
return {}
|
||||
|
||||
@api.model
|
||||
def get_empty_list_help(self, help):
|
||||
def get_empty_list_help(self, help_message):
|
||||
self = self.with_context(
|
||||
empty_list_help_document_name=_("product"),
|
||||
)
|
||||
return super(ProductTemplate, self).get_empty_list_help(help)
|
||||
return super(ProductTemplate, self).get_empty_list_help(help_message)
|
||||
|
||||
@api.model
|
||||
def get_import_templates(self):
|
||||
|
||||
Reference in New Issue
Block a user