diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index fdb7961e094..509643801ff 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -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 = "%s" % (email, email) sub_title = _('Use the top left Create button, or send an email to %s to test the email gateway.') % (email_link) - return '

%s

%s

' % (help_title, sub_title) + return super().get_empty_list_help( + f'

{help_title}

{sub_title}

' + ) # ------------------------------------------------------------ # BUSINESS diff --git a/addons/crm_iap_mine/models/crm_iap_lead_mining_request.py b/addons/crm_iap_mine/models/crm_iap_lead_mining_request.py index c2c5af9535f..5796a61cff9 100644 --- a/addons/crm_iap_mine/models/crm_iap_lead_mining_request.py +++ b/addons/crm_iap_mine/models/crm_iap_lead_mining_request.py @@ -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 '

%s

%s

' % (help_title, sub_title) + return super().get_empty_list_help( + f'

{help_title}

{sub_title}

' + ) def _prepare_iap_payload(self): """ diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py index 5b39be9fb28..ba9ac39052e 100644 --- a/addons/hr_recruitment/models/hr_recruitment.py +++ b/addons/hr_recruitment/models/hr_recruitment.py @@ -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 = "%s" % (email, email) nocontent_values['email_link'] = email_link - nocontent_body += """

%(email_link)s

""" + nocontent_body += """

%(email_link)s

""" - 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): diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 79412950823..1a8c7b837f5 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -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 = "%(email)s" % {'email': alias.display_name} if nothing_here: - return "

%(dyn_help)s

" % { + return super().get_empty_list_help("

%(dyn_help)s

" % { '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

%(dyn_help)s

" % { - 'static_help': help, + if "oe_view_nocontent_alias" not in help_message: + return super().get_empty_list_help("%(static_help)s

%(dyn_help)s

" % { + '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 "

%(dyn_help)s

" % { + return super().get_empty_list_help("

%(dyn_help)s

" % { 'dyn_help': _("Create new %(document)s", document=document_name), - } + }) - return help + return super().get_empty_list_help(help_message) # ------------------------------------------------------ # MODELS / CRUD HELPERS diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 5de10fb8b43..34d64f50fb0 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -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): diff --git a/addons/product/models/product_product.py b/addons/product/models/product_product.py index 0da0554d3f9..2174378936f 100644 --- a/addons/product/models/product_product.py +++ b/addons/product/models/product_product.py @@ -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 diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index bf0ae56664a..79d97d05937 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -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):