Partner Merge User Consolidation
base_partner_merge_user_consolidation · OCA/partner-contact
-
Security25/25No findings
-
Activity25/25Last human commit 6 months ago
-
Required by5/250 modules depend on it
-
Maturity12/25In 2 Odoo series since 16.0
Heuristic over the facts below, not an audit · How it's computed
Migration considerations
- Raw `cr.execute()` INSERT/UPDATE/DELETE bypasses the ORM (no compute/constrains/tracking/mail): `UPDATE res_users SET partner_id = %s WHERE id = ANY(%s)` - re-check the table/column names still match after upgrading. (2 occurrences in this file) migration-raw-sql-write · source
Migration review checklist, not a compatibility verdict. "Migrating to X.0" applies once you upgrade to that version; "Since X.0" means this version already ignores or rejects that code. Methodology
Description
This module extends the standard Merge Contacts wizard in Odoo (base.partner.merge.automatic.wizard) so that user accounts are also consolidated when you merge duplicate contacts. Odoo allows you to merge two (or more) contacts into one. This is great for deduplication.
However, when both of those contacts are linked to different users (res.users), Odoo does not merge or clean up those users. After the merge you can end up with:
- Multiple logins pointing at the same final contact.
- Confusing access rights: which login should this person actually use?
- Compliance issues: inactive/old accounts still exist and could still log in.
This module fixes that:
When you merge contacts and Odoo finishes the normal merge:
- If the resulting contact has 0 or 1 linked users:
- Nothing extra happens.
- If the resulting contact has 2+ linked users:
- The module chooses one user account to keep:
- The account with the most recent login date (field
login_date, which reflects the last res.users.log record). - If nobody has ever logged in, it falls back to the most recently created user.
- The account with the most recent login date (field
- That "kept" user is:
- Forced to stay active.
- Explicitly linked to the surviving contact partner.
- All other users are archived:
- They are set inactive.
- Their
loginis scrambled to a unique value like__merged_user_<id>_oldloginso they can no longer authenticate and so their old login can be reassigned if desired.
- Security groups are merged:
- Any groups on the archived users are added to the kept user.
- Odoo's standard
res.userswrite() logic will automatically:- add all implied groups,
- normalize mutually exclusive role groups,
- enforce "internal vs portal vs public" constraints.
- The module chooses one user account to keep:
Dependencies
- Odoo dependencies
-
odoo/odoo:- base
- Python dependencies
- None
- System dependencies
- None
- Required by
- None
Code analysis
Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.
Views touched 0
No views found for this module.
HTTP endpoints 0
No HTTP endpoints found for this module.
Models touched 1
No new fields.
Public methods (0)No public methods.
Loading…