跳至内容
菜单
此问题已终结
1 回复
1110 查看

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

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
0
12月 24
1513
1
5月 24
2590
3
5月 24
2086
1
2月 24
4103
1
12月 23
2418