Contributors mailing list archives

contributors@odoo-community.org

RE: Partner unicity

by
johan
- 17/04/2018 16:58:09

Dear Alexis,

 

In our CRM module, we have tests on address, phone, fax, mobile and e-mail. When one of these are equal, you get a warning. You can than accept ( when 2 partners share the same e-mail or address ), liberate ( the phone is removed from the other partner ) or of course see that you are duplicating and go to the existing partner. For the address, we have a database with all ( Belgium ) streets and community’s so that users cannot write a street falsely. VAT must be unique ( I don’t understand that’s not so in Odoo in the first place ! ). We also do a check in the EU database to see a VAT number is correct.

We changed a lot in the partner layout ( we have under partner function addresses and contacts with all of these. Any partner can also be a contact for another partner. And company’s can be grouped as mother / child / brother ). So you cannot use our modules 1 to 1 in standard Odoo. And we are not a computer company, so our code is probably not always the best possible -) But when you are interested and you send me an e-mail, I’m glad to send you the modules, so you can see how we did it. We are on Odoo 10 CE.

 

With kind regards,

 

 

Van Hirtum Johan

 

 

Van: Alexis de Lattre [mailto:alexis.delattre@akretion.com]
Verzonden: dinsdag 17 april 2018 18:32
Aan: Contributors
Onderwerp: Partner unicity

 

Dear OCA friends,

As you know, it is often difficult to keep a database without duplicate entries in the partner table. Odoo users often create a new customer/supplier in the database without prior search to see if this customer/supplier already exists. I know that the CRM module has a tool to merge partners, but I'd like to work on technical solutions that would help prevent duplicates, instead of trying to fix them after they occur. I'm not trying to find a perfect solution that avoid all duplicates because I think it's impossible, but I'd like to find pragmatic solutions that would block as many duplicates as possible.

I have several ideas for this ; each idea could be a module to develop in the OCA :

* partner_email_unique :

Would add an sql constraint on the email field. To make it more efficient, this module could also inherit create to strip() and lower() the email field, so that the constraint is more efficient.

* partner_mobile_unique :

Would add an sql constraint on the mobile field. To make it more efficient, it would depend on base_phone, so that we are sure that the phone fields are "clean" and written in the standard E.164 format (+33 4 72 08 08 87).

 

* partner_vat_unique :

Would add a constraint on the vat field... but unfortunately the 'vat' field is synchronised between parent and child partners (cf https://github.com/odoo/odoo/blob/10.0/odoo/addons/base/res/res_partner.py#L411), so we cannot just add an SQL constraint... We would also need to have "clean" VAT numbers (inherit create to strip(), upper() and replace(' ', '')). Ideas are welcomed to find another option than SQL constraint without too much performance impact.

This could be extended to country-specific company numbers via localization modules...


Obviously, it is not possible to put a unique constraint on the phone nor fax field (in the same company/family, several people may share the same fixed phone or fax number). It would also be stupid to put a constraint on the name field, as several people can have the same name.

SQL constraint should certainly include the 'company_id' field (i.e. "unique(email, company_id)"), because, in multi-company environments, partners are sometimes not shared between companies.

All ideas and experiences are welcomed before I start to write modules on this topic. I haven't searched deeply if there are existing OCA modules on this topic, so please mention them if you know some.

Regards,


--

Alexis de Lattre
Akretion France - 35B rue Montgolfier - 69100 Villeurbanne - France

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe