Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1169 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 24
1546
1
thg 5 24
2630
3
thg 5 24
2144
1
thg 2 24
4193
1
thg 12 23
2479