Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
3338 Widoki

I would like to set email formatting to plain text.

This is because when Odoo sends emails they are in html and when someone replies to that email with his huge footer it creates big mess inside mail thread. If we could set mail type to plain text there should be less possibily for too big footers.

How do I do this? Preferably with custom module.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Marcus,


Yes, this can be done with a custom module.


You can override the email sending method and convert the HTML body to plain text before it's sent. One way is to strip out HTML tags from body_html like this:



from odoo import models

import re


class MailMail(models.Model):

    _inherit = 'mail.mail'


    def _send(self, auto_commit=False, raise_exception=False):

        if self.body_html:

            self.body_html = re.sub('<[^<]+?>', '', self.body_html)

        return super()._send(auto_commit=auto_commit, raise_exception=raise_exception)



This will force outgoing emails to plain text. It's basic, but should reduce clutter from HTML replies and footers.



Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
gru 22
4908
0
sie 19
3812
1
sie 19
3405
0
lut 24
1747
0
kwi 21
2002