While creating customers directly or through various interfaces, multiple customers with the same name are being created twice and thrice.Is there any option to give a validation to check a newly entered customer name exists or not?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi,
The name for a customer will not be unique. There wll be so many customers having same name. One thing you can do is to make the reference field (ref) required and add a unique constraint for that field.
For example in my company there are two customers with the name Sunil Kumar. So we provide different reference for both the customers. Like CustRef#0036 and CustRef#0665
Hi,....How ref is used can u explain with an example..Thx in advance
For instance, you could try providing a customer ID value generated @ reference field using SEQUENCE. So, that it can be used unique and also there can be many customers with a same name.
Hi,
You can add _sql_constraints for name field.
Create partner.py file add below code in py file
class res_partner(osv.osv):
_inherit = 'res.partner'
def create(self, cr, uid, vals, context=None):
if context is None:
context = {}
if vals.has_key('name'):
exis_data_id = self.search(cr, uid, [('name','=', vals['name'])])
if exis_data_id:
raise osv.except_osv(_('Invalid Action!'), _('Name already exist.'))
return super(res_partner ,self).create(cr, uid, vals, context)
res_partner()
What _sql_constraints for name field are to be added?In which file can I find the name field as i was not able to find it out in the sales module.
update ans please check it.
Which is the file to which this code has to be added?
for res.partner object
Where your code related res.partner
in partner.py file.
yes in partner.py file.
but the existing module cannot be edited no?New class are to be added in newly created module
Then add it in newly created module. where you define res.partner class
which are the files to be included in the new module?how to link the new module with the res.partner class.What are the contents to be given in the files created for the new folder?
I have update ans pls check it
Where is the partner.py to be created?
Create new module and add this file put newly created module in addons directory update module list and install it.
I installed a new module customer_validation for the above purpose and added the code in py file but now the issue is the validation does not work.Still I can add a name and save it which already exists.
update answer check it
still the duplicate entries can be made after the code has been updated.The same name can be entered and saved.
i have tested this code @ my end its work fine. It not allow to enter same name.
let me explain what all i have done.I first created a new module with files _init_.py , _openerp_.py and py file which includes the given code.
_init_.py contains import (file name of py file)
_openerp_.py contains general data as in other modules.And the .py file contains the above updated code.And then the module was added to the addons folder and the openerp was updated .When it was listed in the Installed modules list,it was installed to the modules and once again the modules list was updated so that it can be used.After doing all these procedures when i tested by entering the customer name that already existed,the expected validation didnt work
hi done ?
No Jack still in dilemma.validation not working.
Create module __init__.py, __openerp__.py and partner.py add code in partern.py install module it will work.