Partner Match
The same partner, recognized the same way
Technical module: one place for the rules that decide whether two partner records are the same, so the modules that look for an existing partner (marketplace import, duplicate finder, trial balance import) recognize the same partner the same way.
It adds no fields, data, menus, scheduled actions or record rules, and changes no behavior by itself: it only provides functions that other modules call.
Normalization (deltatech_partner_match.tools.partner_match, plain Python):
- Namelowercase, without diacritics, punctuation and legal forms (one list for Romania and the EU: SRL, SA, PFA, II, GmbH, Ltd, SARL, KFT...), words sorted. "S.C. Popescu Ion S.R.L." and "ion popescu srl" give the same key.
- VATalphanumerics only, without the country prefix and the leading zeros ("RO 012.345" = "12345"); the check digit of a Romanian CUI or CNP, or of an EU VAT number, with
python-stdnum. - PhoneE.164 (
+40722123456) with the same rule Odoo uses forphone_sanitized(a possible and valid number, withphonenumbers); without the library, the Romanian formats and the numbers written with an international prefix. For bulk comparison, the last nine digits. - EmailOdoo's own
email_normalize.
Matching:
name_similarity(0-1) pairs every word with the closest word of the other name, so a shared surname alone does not make two people alike: use it to decide whether two records are the same partner.token_sort_ratioandsimilar_pairs(0-100) compare whole names, in bulk;rapidfuzzis used when installed,difflibotherwise, on limited blocks. Use them to propose pairs for review.res.partner._find_similar_partners(values, domain, keys, limit)selects the partners that share the VAT number, the email or the phone ofvalues(never a name alone), and returns them with a score and the keys they share. When both sides are in two counties that both have a locality of that name ("Satu Nou" in Bacău and in Iași), the street and the city do not count. Whether one is reused is decided by the calling module.
phonenumbers, rapidfuzz and unidecode are optional: the results stay the same without them on
the exact keys, and slightly coarser on the phones of other countries.
For developers. Add deltatech_partner_match to depends, then:
from odoo.addons.deltatech_partner_match.tools import partner_match as pm
pm.normalize_name("S.C. Popescu Ion S.R.L.") # "ion popescu"
pm.normalize_vat("RO 012.345") # "12345"
pm.check_vat("RO18547290") # True
pm.normalize_phone("0722 123 456") # "+40722123456"
pm.phone_key("+40 722 123 456") # "722123456"
pm.name_similarity("Ana Popescu", "Ion Popescu") # 0.67
candidates = self.env["res.partner"]._find_similar_partners(
{"name": "Ion Popescu", "phone": "0722 123 456", "email": "ion@example.com", "city": "Cluj"},
domain=[("is_company", "=", False)],
)
# [{"partner": res.partner(42,), "score": 0.94, "name_score": 1.0, "reasons": ["phone"]}, ...]
Need help getting started?
Our 800+ apps on the Odoo Apps Store are used in Odoo implementations across Europe, the Americas, Asia and Africa — by companies we have never even met. That is the advantage of building modules that simply work.
Questions about this module? Write to us — the developers who build it will answer.
More apps by Terrabit
Other modules from the same publisher, built to work together. All apps →
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 377 |
| Technical Name |
deltatech_partner_match |
| License | LGPL-3 |
| Website | https://www.terrabit.ro |
Please log in to comment on this module