A customer company has moved away, the contract has ended, and you want to archive it in Odoo. Odoo responds with an error message: “You cannot archive contacts linked to an active user. You first need to archive their associated user.” If the company has several portal accesses, that means: find each user individually, archive each one individually, go back to the company, archive it again.
We wrote the small module Archive company together with portal users (partner_archive_users) for Odoo 19 for this purpose. Instead of the error message there is a confirmation prompt, and on “Yes” the portal users and the company are archived in one step. The module is available as free software under the AGPL-3 licence on GitHub:
github.com/Alex0176/odoo-partner-archive-users
We have been using the module in our production system at Biricon IT Services since 3 November 2026. It is new, so experience with it is short. Anyone adopting it should read the sections on Scope and Limits .
The problem in standard Odoo
When a contact is archived, Odoo checks whether a user is attached to it, and aborts if so. The check makes sense, because every user needs a contact. For internal users, that is, employees, the block is also intended. For customers' portal users, however, it is mostly manual work. Every customer company with portal access, for example to view invoices and tickets, needs the same procedure when being archived:
- Search for the users of the company and its contact persons,
- archive each one individually,
- go back to the company,
- archive the company.
The solution: a confirmation prompt
The module extends the route Action → Archive on the contact, in the form as in the list. If active portal users are attached to the selected company or to its contact persons, a dialog opens with the question “Do you really want to archive the company? There are still active users in the system.” Below it are the users concerned, with name, login and contact.
- Yes, archive company and users: First the users are archived, then the company.
- Cancel: Nothing changes.
- No portal users present: Odoo behaves as before, no dialog appears.
What is archived and what is not
The scope is deliberately narrow:
- Only portal and public users (
share = True). Internal users are never archived by this route. If an employee account is attached to the contact, Odoo's error message remains. This way nobody accidentally locks out an employee by archiving a company. - Contact persons stay active as contacts. Only their portal accesses are archived. This corresponds to standard Odoo, which likewise does not touch the child contacts when a company is archived.
- Only the archive route of the user interface. A direct
write({'active': False}), for example in an import or script, runs unchanged into Odoo's check.
Technical implementation
The module adds no new fields to existing models. It consists of an extension of res.partner.action_archive and a wizard (partner.archive.users.wizard) that appears as a dialog.
| Component | Purpose |
|---|---|
action_archive on the contact | Searches for active users with share = True that are attached to the contact or (for companies) to contacts of the company. If there are any, the dialog is returned instead of archiving. |
| Wizard | Stores the company and the users found, displays them and, on “Yes”, carries out the archiving with the context key archive_linked_users. |
Context skip_archive_users_wizard | Switches off the dialog. Odoo's check then applies again. |
| Access | Internal users (base.group_user) may create and use the wizard. |
| Translation | German (de.po) and template (.pot) are included. |
The users are searched for and archived with elevated rights (sudo). This makes the dialog work even for users without access to user administration. The downside is described under Limits.
A finding: the test was green, but the dialog was broken anyway
On first use, the module had an error that the automated tests did not find. On the first click on “Archive” in the interface, instead of the dialog the Odoo error screen appeared with Cannot read properties of undefined (reading 'map').
The cause: the web client calls action_archive directly and executes a returned action without further processing. In doing so it necessarily reads the action's views key. Our action had only view_mode. For actions from buttons with type="object" the server completes them beforehand (clean_action in call_button), but not for the direct call of action_archive. The tests called the method only in Python, where the missing field went unnoticed.
The fix is one line ("views": [(False, "form")]), plus a check in the test that demands exactly this key. Nothing was archived in the process. The lesson: if you return an action from a method that the client calls directly (action_archive, action_unarchive and similar), you should always include views.
Installation
git clone https://github.com/Alex0176/odoo-partner-archive-users.git
ln -s /pfad/odoo-partner-archive-users/partner_archive_users /pfad/addons/
odoo-bin -c odoo.conf -d <datenbank> -i partner_archive_users --stop-after-init
The dependencies are base and contacts. After installation, the Odoo service must be restarted, because the module contains Python code. If you run a production system, install the module on a copy of the database first.
Limits
- Permission. Because the users are archived with elevated rights, anyone who is allowed to archive a contact can also archive that company's portal accesses via the dialog. This does not apply to internal users. If you want to secure portal accesses more finely, you have to adapt the module.
- No automatic restoring. If the company is activated again later, the users remain archived. They must be reactivated by hand.
- Contacts only. The module concerns companies as contacts (
res.partner). Archiving an Odoo company (res.company) has different checks, for example if it is still the default company of users. The module is not intended for that. - Tested only for Odoo 19.0 Community. We have not tested it for other versions.
Frequently asked questions
Why are employees not archived as well?
An internal user has rights in the system and is usually linked to their own data, tasks and permissions. Locking them out as a side effect of archiving a company is too risky for us. Odoo's error message therefore remains.
Can I switch off the confirmation prompt?
In code, via the context skip_archive_users_wizard. There is no setting in the interface. If you uninstall the module, you get Odoo's standard behaviour again.
Under which licence is it released?
Under the AGPL-3. Bug reports and improvements are welcome as an issue in the GitHub repository .
Support from Biricon IT Services
We look after Odoo installations for small and medium-sized businesses: from implementation through customisations and migrations to ongoing operation. If you want to simplify processes such as archiving customer companies in Odoo, set up a portal for your customers, or bring a module safely into your production instance, we will be glad to help. More in-house developments: Document numbers from prefix, year and counter, Firmenbuch and address validation for Austrian customers and Product sets in the quotation as a section.
As of: 3 November 2026. Module version 19.0.1.0.0 with the fix from the same day. All names and logins in the figures are freely chosen.