Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1173 Ansichten

I need to group emails received by their domain name.

The regex rule to identify the said domains would be 

regex_pattern = r"@(.+)$"


How to embed such a regex rule into an odoo filter?


sincerely

Avatar
Verwerfen
Beste Antwort

group by can use a callable or a field to group, so you can create a computed field to get the domain and then use the computed field to group.

something like this I suppose but I didn't test it

# Python
    email_domain = fields.Char(compute='_compute_email_domain')

    @api.depends('email')
    def _compute_email_domain(self):
        for record in self:
            record.email_domain = record.email.split('@')[1] if '@' in record.email else None
# XML



https://github.com/odoo/odoo/blob/17.0/odoo/models.py#L6106

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Dez. 24
1552
1
Mai 24
2640
3
Mai 24
2157
1
Feb. 24
4204
1
Dez. 23
2485