Repository: OCA/social

Issue:
[14.0] mail_debrand empty content for sign up
Using mail_debrand, the content of the mail sent at sign up is empty (headers and footer are properly filled) :
```html
    <!-- CONTENT -->
    <tr>
        <td align="center" style="min-width: 590px;">
            <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                <tr><td valign="top" style="font-size: 13px;">
                    </td></tr>
                <tr><td style="text-align:center;">
                  <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;">
                </td></tr>
            </table>
        </td>
    </tr>
```

Without mail_debrand module installed I get the following content : 
```html
    <!-- CONTENT -->
    <tr>
        <td align="center" style="min-width: 590px;">
            <table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
                <tr><td valign="top" style="font-size: 13px;">
                    <div>
                        Cher(e) test,<br/><br/>
                        Vous avez été invité par Admin LE FILAMENT à rejoindre Odoo.
                        <div style="margin: 16px 0px 16px 0px;">
                            <a href="removed_url" style="background-color: #875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px; font-size:13px;">
                                Accepter l'invitation
                            </a>
                        </div>
                        Votre nom de domaine Odoo est: <b><a href="removed_url">removed_url</a></b><br/>
                        Votre courriel de connection est: <b><a href="removed_url" target="_blank">removed_email</a></b><br/><br/>
                        Jamais entendu parler d'Odoo? C’est un logiciel de gestion tout-en-un apprécié par plus de 3 millions d’utilisateurs. Il améliorera considérablement votre expérience de travail et augmentera votre productivité.
                        <br/><br/>
                        Faites un tour dans la section <a href="https://www.odoo.com/page/tour?utm_source=db&amp;utm_medium=auth" style="color: #875A7B;">Odoo Tour</a> afin de découvrir l'outil.
                        <br/><br/>
                        Enjoy Odoo!<br/>
                        --<br/>L'équipe LE FILAMENT 
                    </div>
                </td></tr>
                <tr><td style="text-align:center;">
                  <hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin: 16px 0px 16px 0px;"/>
                </td></tr>
            </table>
        </td>
    </tr>
```

The issue seems related to this block : https://github.com/OCA/social/blob/02467d14fa4b2ade959ced981f3a0411d46e1d26/mail_debrand/models/mail_render_mixin.py#L51-L52 where the full div is removed because of Odoo tour section.

I am not sure how to address this without breaking the way this module works for other mail templates, any idea would be welcome !


Discussion:
Workaround is to update e-mail template auth_signup.set_password_email to remove the following lines :
https://github.com/odoo/odoo/blob/5bd8596410f8584ce430567ebfec0a42fb40f755/addons/auth_signup/data/auth_signup_data.xml#L152-L153

Hello @remi-filament 😄 !!! Do you want to review this PR? https://github.com/OCA/social/pull/911

It doesn't solve your issue, but is the first step.

@moduon MT-787
@Shide did you find any hint on how to fix this issue?

Resolving patch:
diff --git a/mail_debrand/__manifest__.py b/mail_debrand/__manifest__.py
--- a/mail_debrand/__manifest__.py
+++ b/mail_debrand/__manifest__.py
@@ -20,6 +20,9 @@
     "license": "AGPL-3",
     "installable": True,
     "depends": ["mail"],
+    "data": [
+        "data/ir_config_parameter.xml",
+    ],
     "development_status": "Production/Stable",
     "maintainers": ["pedrobaeza", "joao-p-marques"],
 }
diff --git a/mail_debrand/models/mail_render_mixin.py b/mail_debrand/models/mail_render_mixin.py
--- a/mail_debrand/models/mail_render_mixin.py
+++ b/mail_debrand/models/mail_render_mixin.py
@@ -22,6 +22,23 @@ def remove_href_odoo(
         if type(value) is bytes:
             value = value.decode()
         has_odoo_link = re.search(r"<a\s(.*)odoo\.com", value, flags=re.IGNORECASE)
+        extra_regex_to_skip = (
+            self.env["ir.config_parameter"]
+            .sudo()
+            .get_param("mail_debrand.extra_regex_to_skip", "False")
+        )
+        # value is required field on ir config_parameter, so we have added
+        # safety check for "False"
+        if (
+            has_odoo_link
+            and extra_regex_to_skip
+            and extra_regex_to_skip.strip().lower() != "false"
+        ):
+            # check each regex to be skipped
+            for regex in extra_regex_to_skip.split(","):
+                if re.search(r"{}".format(regex), value, flags=re.IGNORECASE):
+                    has_odoo_link = False
+                    break
         if has_odoo_link:
             # We don't want to change what was explicitly added in the message body,
             # so we will only change what is before and after it.


Test patch: