Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1230 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
dec. 24
1622
1
mai 24
2746
3
mai 24
2241
1
feb. 24
4294
1
dec. 23
2569