'Helper: return a Warning exception with the given message where the %(field:xxx)s
and/or %(menu:yyy)s are replaced by the human readable field\'s name and/or menuitem\'s
full path.
Usage:
Just include in your error message %(field:model_name.field_name)s to obtain the human
readable field\'s name, and/or %(menu:module_name.menuitem_xml_id)s to obtain the menuitem\'s
full path.
Example of use:
from odoo.addons.base.res.res_config import get_warning_config
raise get_warning_config(cr, _("Error: this action is prohibited. You should check the field %(field:sale.config.settings.fetchmail_lead)s in %(menu:sales_team.menu_sale_config)s."), context=context)
This will return an exception containing the following message:
Error: this action is prohibited. You should check the field Create leads from incoming mails in Settings/Configuration/Sales.
What if there is another substitution in the message already?
You could have a situation where the error message you want to upgrade already contains a substitution. Example:
Cannot find any account journal of %s type for this company.
You can create one in the menu:
Configuration\Journals\Journals.
What you want to do here is simply to replace the path by %menu:account.menu_account_config)s, and leave the rest alone.
In order to do that, you can use the double percent (%%) to escape your new substitution, like so:
Cannot find any account journal of %s type for this company.
You can create one in the %%(menu:account.menu_account_config)s.'

@api.model_cr_context
def get_config_warning(self, msg):

    self = self.sudo()
    regex_path = '%\\(((?:menu|field):[a-z_\\.]*)\\)s'
    references = re.findall(regex_path, msg, flags=re.I)
    values = {}
    action_id = None
    for item in references:
        (ref_type, ref) = item.split(':')
        if (ref_type == 'menu'):
            (values[item], action_id) = self.get_option_path(ref)
        elif (ref_type == 'field'):
            values[item] = self.get_option_name(ref)
    if action_id:
        return RedirectWarning((msg % values), action_id, _('Go    to    the    configuration    panel'))
    return UserError((msg % values))
