Partner Merge in Bulk
Merge duplicates by VAT number, in bulk
Merges partner records that share the same VAT number, in bulk.
Odoo's own merge wizard walks the foreign keys group by group: for every pair it goes through all
~158 columns that reference res_partner. Fine for a handful of duplicates; for thousands of groups
it means hundreds of thousands of statements and does not finish in any reasonable window.
This module inverts the loops — one statement per column for the whole batch — and keeps foreign keys enabled throughout, so integrity is guaranteed by PostgreSQL rather than by the procedure being right. On a production database of 538.000 partners, merging 5.350 records took about four and a half minutes.
Merge batches. Settings > Partner Merge > Merge Batches. A batch goes through Analyze, Simulate, Apply and, once applied, Verify. You choose the categories of groups that enter the batch, how many groups (Group Limit, 0 for all) and whether the absorbed records are deleted or archived (Archive instead of delete). The Groups tab lists each group with the kept record, the absorbed ones and their names; Report holds the simulation or merge report, and All groups by category the full classification. Partners are grouped by VAT number and company, so partners of different companies are never merged together.
Safety. The simulation is not a flag you can forget: it runs the whole merge inside a savepoint and rolls it back, so it cannot write even if something is wrong. Applying is a distinct step, reserved to the Partner Merge / Apply group (system administrators have it), checks that every partner of the batch is in your companies and that you may change or delete it, and refuses to finish if any reference is left pointing at an absorbed record. Partner Merge / Prepare and simulate can analyze and simulate, but not apply. Verify compares the result with the figures taken at the analysis: invoices, sales orders and unreconciled balance per kept record.
What it does not touch by itself. Groups are classified A (one record holds the documents, the rest are empty), B (documents on a single record), C (invoices spread over several records) and D (unreconciled balance on several records). A batch takes A and B by default; C and D move figures between ledgers and belong with the accountant. Also left out: groups holding your own company record, groups with portal users on more than one record, and groups whose names differ completely on the same VAT number.
Kept record. Chosen by document volume — most invoices, then most sales orders, then oldest. Since that is not the same as name quality, the surviving record is flagged when its name looks mangled at import, with the names of the absorbed records alongside for correction.
Indexes. When foreign-key columns towards partners have no index, the batch shows a warning and a Create the indexes button, because deleting partners would otherwise scan those tables for each record.
The same procedure also exists as stand-alone SQL scripts, for when it has to be run outside Odoo by
the database administrator. They are kept in the source repository of the suite
(scripts/partner_merge/) and are not part of the module package downloaded from Odoo Apps.
Finding duplicates beyond the VAT number. Settings > Partner Merge > Find Duplicates looks for partners that are probably the same record, typically individuals created twice by an import or an online order, and leaves the decision to you, group by group. It does not change any partner.
- Exact matches on the VAT number (without the country prefix), the phone (E.164, so
0722 …and+40 722 …meet), and the email (lowercase). - Similar names (without diacritics or legal forms, words sorted) at the same street or postcode, or similar names alone if you choose so. Names are compared only inside a block (same city, or same first letters), so large databases are not compared all against all.
- Each group shows its score and the reason ("same phone +40722…", "name 92% + same street"). Merge opens the standard Odoo merge wizard on the group, where you choose the record to keep. Not duplicates remembers the pair, so later scans skip it.
- Left out: partners of internal users and of your companies, a partner and its own contacts, invoice and delivery addresses of the same customer, partners of different companies, and values shared by too many partners (placeholders, switchboards), which are listed in the report.
The name comparison uses rapidfuzz when it is installed on the server. Without it, the scan falls
back to Python's difflib, which is slower and only compares blocks of up to 1,500 partners; the
larger blocks are listed in the report. phonenumbers and unidecode are used the same way, if
present. None of them is required.
20.0.1.2.1 (2026-11-27)
- Migration to Odoo 20.
- Merge in Bulk takes only the parent companies as candidates: on Odoo 20 the contacts of a
Romanian company carry its VAT number and, with
l10n_ro_edi, are also flagged as companies, so they would have been merged into (and deleted with) their own company. - Find Duplicates with Individuals only keeps the contacts of companies among the persons.
- The candidates no longer read
company_registry, removed from the partner in Odoo 20. - Create indexes quotes the table and column names (a table name with capitals or special characters broke the command).
- Merge in Bulk: the table and column names taken from the PostgreSQL catalog are quoted in all the generated statements (remap, deduplication, filling of empty fields).
- Consultant sheet completed against the code: access rights and menu, company scope, index creation after the analysis, filling of empty fields, Back to draft on scans and batches, the error messages of the batch.
19.0.1.2.1 (2026-11-03)
- Description: the stand-alone SQL scripts are kept in the source repository of the suite and are not part of the module package from Odoo Apps (the text pointed to them as if they shipped with it).
- Description: the simulation runs inside a rolled-back savepoint, not a separate transaction.
- Description: added the menus (Settings > Partner Merge), the batch steps and options, the two access groups, the A–D categories and the index warning.
19.0.1.2.0 (2026-10-23)
- Find Duplicates uses the shared rules of
deltatech_partner_match(new dependency, installed automatically: functions only, no data or behavior of its own) instead of its own copy, so a partner is recognized here the same way as in the marketplace import and the trial balance import. Checked on a database of 551,000 partners against the previous rules:- phone and email keys: identical;
- VAT: the leading zeros are dropped (
RO0733329058=733329058); 42 codes change, all phone numbers typed in the VAT field, and the number of VAT groups stays the same; - names: the legal forms KFT, SARL, s.r.o., SPRL and CMI are dropped too (6,294 names), so "Vario KFT" and "Vario" get the same key;
- a phone that is not recognized as a valid number is still compared on its last nine digits, as before.
19.0.1.1.0 (2026-10-23)
- Add: Find Duplicates, a scan for partners that are probably duplicated, on the VAT number, the phone (E.164), the email, and similar names at the same street or postcode. Results are kept as groups with a score and a reason; each group is merged with the standard Odoo merge wizard after you confirm it, or marked as not duplicates so later scans skip it. Partners of internal users and of the companies are left out. The name comparison uses
rapidfuzzif it is installed, otherwisedifflibon limited blocks; no new required dependency. - Romanian translation (
i18n/ro.po) for the whole module. - Consultant sheet (
readme/FISA_CONSULTANT.md) for finding and merging duplicates, with screenshots generated bytests/test_screenshots.py.
19.0.1.0.5 (2026-10-17)
- MERGE-002: Verify on an applied batch checked the working tables of the latest analyzed batch, so after another batch was analyzed it reported the masters, totals and remaining records of that other batch. The snapshot taken at the analysis (expected invoices, sales orders and unreconciled balance per kept record) is now stored on the batch lines, and Verify compares against it and against the batch's own absorbed records. Batches analyzed before this version have no stored snapshot and Verify refuses them with a message instead of showing another batch's figures.
- MERGE-003: the stand-alone SQL scripts in
deltatech/scripts/partner_merge/grouped partners by VAT alone, so a manual run on a multi-company database merged partners of different companies into one master.02_build_map.sqlnow groups and chooses the master per (VAT, company), with shared partners (no company) in groups of their own, as the module does; the progress count in04_verify.sqluses the same grouping.
19.0.1.0.4 (2026-10-09)
- Apps Store banner (banner.json).
19.0.1.0.3 (2026-10-03)
- MERGE-001 (security): the analysis read the partners of all companies and grouped them by VAT alone, and Apply rewrote and deleted them without any company or access check, so an operator limited to one company could merge or delete partners of other companies, and partners kept separately per company were merged into a partner of another company. Now:
- a group is (VAT, company): partners of different companies are never merged together; the batch lines show the company;
- the analysis only takes the partners of the selected companies; shared partners (no company) are taken only for system administrators and users with access to every company;
- Apply refuses a batch with partners outside the user's companies or groups mixing companies, and requires write access (and delete access, unless Archive instead of delete) on the partners.
- Behavior change: operators without access to every company no longer see groups of shared partners, and same-VAT partners of different companies are no longer proposed for merging. The SQL scripts in
deltatech/scripts/partner_merge/are unchanged (database-wide, run by the DBA).
19.0.1.0.2 (2026-09-29)
- Own module icon, instead of the generic gears it had.
19.0.1.0.1 (2026-09-23)
- The merge simulation rolls back its savepoint through
contextlib.suppress(_Rollback)instead ofexcept _Rollback: pass; behavior is unchanged.
19.0.1.0.0 (2026-08-18)
- Add: bulk merge of partners duplicated on the same VAT number, with classification, guards,
simulation on a rolled-back transaction, and verification against a snapshot taken before the
merge. Wraps the SQL procedure from
deltatech/scripts/partner_merge/, validated on a client's staging database (575 records merged in three batches, zero discrepancies on invoices, orders, deliveries and unreconciled balance).
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
|
| Community Apps Dependencies | Show |
| Lines of code | 1468 |
| Technical Name |
deltatech_partner_merge |
| License | OPL-1 |
| Website | https://www.terrabit.ro |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module