Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1118 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
dic 24
1522
1
mag 24
2598
3
mag 24
2100
1
feb 24
4124
1
dic 23
2432