Odoo Help


Making phone a unique filed without list import issues?

John Baldwin
on 1/17/15, 10:01 PM 1,034 views

If I make the field phone unique via sql_constraints in res.partner and crm.leads, what will happen if I attempt to import a list that has one or more existing leads/customers phone numbers in it? Will this throw an error or skip the record all together? If so is there a simple work around for this? The deduplicate leads module does not include phone numbers and I can't imagine why? Does any company in the world want multiple leads/customers with the same phone number?

I am playing wirth this now and thought I should ask before making the changes and wasting my time creating another issue.

Michael Watchorn
On 1/17/15, 10:18 PM

To quote the ever knowledgable Ray Carnes:

If there is already data in the system that violates the constraint, it won't work - because it can't be applied.

The constraint has to be for all records - those that already exist, those that will be added via your module, and those that will be added by other modules.

See this link on the forum to see this in context. Where kaynis was having a problem with his constraint.

Your answer was spot on! Thanks! After further thinking this through I can see a huge problem with making phone a unique field. Importing leads list will break the import if you get a duplicate phone number. A better approach is to import leads leaving assignment as unassigned then to run a check against the phone numbers in crm (for duplicate leads) and res.partner (for existing customers). Additionally by setting up a "Do not call" field boolean I can use invisible to hide the phone field on records that are marked "Do not Call." For my purposes the deduplicate leads part of crm is useless, so I'm working on code to filter the duplicates by existing phone numbers in crm & res,partner and marking them as duplicate leads for review by a manager, who can then mark them dead with the reason duplicate.

John Baldwin
on 1/18/15, 11:40 AM

IT Libertas

--IT Libertas--
| 4 3 7
Saint Petersburg, Russian Federation
--IT Libertas--

Visit us: https://odootools.com/

IT Libertas is a team of developers and automation experts to help you to unlock Odoo ERP system's potential. We have been communicating with end users to whom the software became a main business tool since 2012. As a result, we are proud of dozens of successful Odoo apps developed.

We are open for new ideas and challenges to create the best Odoo tools for business needs all over the world

IT Libertas
On 7/13/16, 8:43 AM

This app - https://apps.odoo.com/apps/modules/9.0/crm_duplicates/ - let make any field unique for partners, leads and opportunities. Odoo would not allow making duplicates

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.


Odoo Training Center

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

Test it now

Question tools

1 follower(s)


Asked: 1/17/15, 10:01 PM
Seen: 1034 times
Last updated: 7/13/16, 8:43 AM