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

Show message on creating there is similar contact in odoo

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

Hi,

If you need to do this from code side, you can add a constrain and check for existing records and then raise a validation error if existing matches found.

You can achieve it by adding the below code in the corresponding model:

@api.constrains('email')
def _check_email_uniqueness(self):
for partner in self:
if partner.email:
existing_partner = self.env['res.partner'].search([
('email', '=', partner.email),
('id', '!=', partner.id)
])
if existing_partner:
raise UserError('Email already exists!')

If you need to achieve it from user interface, you can achieve it using, automated action.

See a similar example depicted here: Prevent Product Duplication without code using automated actions

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
3556
1
thg 7 25
1656
1
thg 8 25
1153
0
thg 5 25
2044
2
thg 4 25
4327