Skip to content

[18.0][FIX] hr_employee_id: use the employee's / current company, not the user's default one - #1644

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-hr_employee_id-company
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-hr_employee_id-company

Conversation

@parabol123654

@parabol123654 parabol123654 commented Nov 1, 2026 •

Copy link
Copy Markdown

hr_employee_id reads its configuration from self.env.user.company_id (the user's default company) instead of the employee's company / the selected company.

Multi-company, user's default company A (random, 5 digits), company B configured with 8 digits (or a sequence), B selected in the company switcher:

  1. Create an employee of B: the ID is generated with A's method/digits/sequence (5 digits instead of 8).
  2. Open Settings (B selected): Employee ID settings show A's values. Saving the Settings for any other change writes A's values into B (the defaults of the related fields come from A), so B's configuration is silently lost.

Fix:

  • _generate_identification_id uses self.company_id or self.env.company (it is called on the new record; @api.model removed accordingly).
  • The Settings defaults use self.env.company.

Test test_multi_company_generation: fails without the fix (5 != 8 on the generated ID; with only the generation fixed, 5 != 8 on the Settings value, and on the company after saving the Settings), passes with it (10/10). The existing test_multi_company_res_config switches user.company_id itself, so it did not catch it.

Assisted-by: Claude Opus 5.5

@parabol123654
parabol123654 force-pushed the 18.0-fix-hr_employee_id-company branch from 3a1d4c4 to d06cfb2 Compare November 2, 2026 00:45
…ser's default one

The ID was generated with the settings of env.user.company_id, so an
employee of another company got an ID from the wrong method, digits or
sequence. The Settings defaults also came from env.user.company_id:
opening Settings in another company showed the default company's
values and saving them overwrote that company's configuration.

Assisted-by: Claude Opus 5.5
@parabol123654
parabol123654 force-pushed the 18.0-fix-hr_employee_id-company branch from d06cfb2 to b185f18 Compare November 14, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants