This question has been flagged
1 Reply
6282 Views

We have Account Numbers assigned to every Customer and Vendor, and this happens during onboarding (outside Odoo).

We are finding users entering Customers and/or Vendors into Odoo when they are already there - they are not checking properly before adding the information.

How can we build a check into Odoo so that the same Customer and/or Vendor doesn't get created more than once.

Customer Account Numbers start with "C" and Vendor Account Numbers start with "S".

Avatar
Discard
Best Answer

One way is to create an Automated Action that is triggered to run when you create and update Contacts:

You may need to install the Automated Action Rules module (if it isn't already installed).


Create a new Automated Action that works on the res.partner (Contact) model.

  • Action To Do is Execute Python Code

  • Trigger Condition is On Creation and Update

  • Code is:

if not record.ref:  
raise Warning("Account Number can't be blank!") 
else: 
existing_partner = env['res.partner'].search([('id','!=',record.id),('ref','=',record.ref)]) 
if existing_partner:   
raise Warning("You can't have the same Account Number in Odoo twice!\n\nAccount Number: " + \
record.ref + " is already in Odoo, assigned to:" + existing_partner.name+ ".")



Given these Contacts in the database:



This is the Warning you will get if you try to save a Contact with an already used Internal Reference:


Avatar
Discard

How can I avoid duplicating in contact?

This post is about Contacts, if you have a different question, please post a different question instead of a comment on a post that is already answered.