[FIX] mail_debrand: Avoid odoo.sh links removal

For URLs like my-customer.odoo.com
Forward of #1181
Issue: #1375
pull/1595/head
Yannis Burkhalter 2025-02-13 14:38:13 +01:00
parent 8a0f8fd2b2
commit deb52b4bd6
No known key found for this signature in database
GPG Key ID: 3DF78DB148BFC3B8
1 changed files with 2 additions and 2 deletions

View File

@ -28,14 +28,14 @@ class MailRenderMixin(models.AbstractModel):
has_dev_odoo_link = re.search( has_dev_odoo_link = re.search(
r"<a\s(.*)dev\.odoo\.com", value, flags=re.IGNORECASE r"<a\s(.*)dev\.odoo\.com", value, flags=re.IGNORECASE
) )
has_odoo_link = re.search(r"<a\s(.*)odoo\.com", value, flags=re.IGNORECASE) has_odoo_link = re.search(r"<a\s(.*)www\.odoo\.com", value, flags=re.IGNORECASE)
if has_odoo_link and not has_dev_odoo_link: if has_odoo_link and not has_dev_odoo_link:
# We don't want to change what was explicitly added in the message body, # 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. # so we will only change what is before and after it.
if to_keep: if to_keep:
value = value.replace(to_keep, "<body_msg></body_msg>") value = value.replace(to_keep, "<body_msg></body_msg>")
tree = html.fromstring(value) tree = html.fromstring(value)
odoo_anchors = tree.xpath('//a[contains(@href,"odoo.com")]') odoo_anchors = tree.xpath('//a[contains(@href,"www.odoo.com")]')
for elem in odoo_anchors: for elem in odoo_anchors:
parent = elem.getparent() parent = elem.getparent()
# Remove "Powered by", "using" etc. # Remove "Powered by", "using" etc.