I had the issue of duplicated customer names in Openerp..I'm trying to create a module for OpenERP 7 that prevents double partner records. For instance if I create a contact with the name: "Ajay."; I want an error prompt to come up when I make another contact with the exact same name, and saving is prevented.
After reading up on the web and the help section here, the best way to accomplish this seemed to use an sql constraint. In some of the topics I've read it was recommended to create a new module just for this.
I have created a module, which I named Customer_validation and I am able to install it on my database on the server. However, my code does not seem to be working - I can still enter double partner names without validation.
This is my first module, so I may have very well made a mistake. Is there something that is missing from my code, or if I forgot something in my module?
Folder name: "Customer_validation" Folder contains: 3 files
**__init__.py**
import crm
**__openerp__.py**
{
"name" : "customer_validation",
"version" : "0.1",
"description" : """
Adds partner validation
""",
"author" : "Sneha",
"depends" : ['crm'],
"category" : "Generic Modules/Base",
"init_xml" : [],
"demo_xml" : [],
"active": False,
"installable": True
}
**Customer_validation.py**
from osv import fields, osv
class res_partner(osv.osv):
_inherit = 'res.partner'
_sql_constraints = [
('name', 'UNIQUE (name)', 'The name of the partner must be unique !')
]
res_partner()