Hi i am looking for the settings on automated action fields and the python code to avoid my staff from creating duplicate contacts in Odoo V14. I did similar automated action on product internal reference which works perfectly but cannot manage to do so for the contacts.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
You can avoid creating a duplicate contact by generating a error message by checking the unique field.
For example:
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.onchange('name')
def _check_name(self):
partner = self.search([])
name = partner.mapped('name')
if self.name:
if self.name in name:
raise ValidationError('Duplicate Customer Name.')
Here, it will generate a validation error if the creating customer name already exists in contacts. And it will prevent creating customers with the same name.
Regards
Hello,
Thank you for replying so promptly, I have not done any coding on the forms before, I was able to locate res.partner in models but within the model there are a lot of options to go about. any chance you can guide me which field I should apply this code too.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 11 23
|
1128 | ||
|
1
thg 9 23
|
2320 | ||
|
1
thg 8 23
|
1571 | ||
|
2
thg 9 20
|
2574 | ||
|
0
thg 10 23
|
8266 |
If you need any help regarding coding you can contact with us: softwarebox18@gmail.com