Skip to content

[18.0][FIX] hr_employee_firstname: create an employee from a user - #1664

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-hr_employee_firstname-create-from-user
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-hr_employee_firstname-create-from-user

Conversation

@parabol123654

@parabol123654 parabol123654 commented Nov 10, 2026 •

Copy link
Copy Markdown

When hr.employee.create() gets a user_id and no name, core takes the name of the user (vals['name'] = vals.get('name', user.name)). This module checks the name before core runs and raises:

ValidationError: No name set.

So hr.employee.create({"user_id": user.id}) fails with this module installed. I found it by running the core hr tests with this module installed: TestChannel creates its employee this way and fails in setUpClass.

The fix: when none of firstname, lastname or name is given but user_id is, the module takes the name of the user first, then splits it as usual. An employee created with no name and no user still raises No name set., as test_no_name checks.

Test: test_create_from_user creates an employee from a user named "Jean-Pierre Carnaud".

  • Without the fix: No name set.
  • With the fix: name "Jean-Pierre Carnaud", firstname "Jean-Pierre", lastname "Carnaud". The module tests and all the core hr tests pass (73 tests).

Assisted-by: Claude Opus 5.5

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @luisg123v, @Savoir-faire Linux,
some modules you are maintaining are being modified, check this out!

hr.employee.create() takes the name of the linked user when no name is
given, but this module raised "No name set." before reaching it, so an
employee created with only a user_id could not be created.

Take the name of the user in that case, before splitting it.

Assisted-by: Claude Opus 5.5
@parabol123654
parabol123654 force-pushed the 18.0-fix-hr_employee_firstname-create-from-user branch from 70313b8 to 755b5eb Compare November 14, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:hr_employee_firstname Module hr_employee_firstname series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants