تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3635 أدوات العرض

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.

الصورة الرمزية
إهمال

If you need any help regarding coding you can contact with us: softwarebox18@gmail.com

أفضل إجابة

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.

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
نوفمبر 23
1188
1
سبتمبر 23
2543
1
أغسطس 23
1671
2
سبتمبر 20
2706
0
أكتوبر 23
8419