Odoo Help

0

0
1 Answer
1
Avatar

Ray Carnes

--Ray Carnes--
2595
| 5 2 8
Highland, Stati Uniti d'America
--Ray Carnes--

Business Analyst - Custom Projects

https://www.linkedin.com/in/raycarnes

Ray Carnes
28/09/18, 20:41

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:


Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now