Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] hr: filter employee_ids based on the current company #164294

Conversation

alsh-odoo
Copy link
Contributor

This traceback occurs when the user clicks on the employee smart button.

To reproduce this issue:-

  1. Install Employees, contacts without demo data
  2. Enter into multi-company environment by creating a new company
  3. Now create a new employee with company as new company and
    related user in the Hr settings as Administrator
  4. Now switch to single company environment by disabling new company
  5. click on the employee smart button from contact module for the
    Administrator record
  6. A traceback occurs

Error:-

ValueError: Expected singleton: hr.employee(1, 3)

Because after the commit {1 } from saas-17.1
when we have multiple records for a record in multi-companies
and shift to single company, the other company records are also accessible.

Because of that it leads to the above traceback when trying to access id from self.employee_ids

return {
'name': _('Employee'),
'type': 'ir.actions.act_window',
'res_model': 'hr.employee',
'res_id': self.employee_ids.id,
'view_mode': 'form',
}

[1] 3c8e449

After applying this commit will resolve this issue by filtering
the employee_ids based on the current company record id

sentry-5289238474

This traceback occurs when the user clicks on the employee smart button.

To reproduce this issue:-

1) Install "Employees", "contacts" without demo data
2) Enter into multi-company environment by creating  a new company
3) Now create a new employee with company as new company and
  related user in the "Hr settings" as "Administrator"
4) Now switch to single company environment
5) click on the "employee" smart button from contact module for the
  "Administrator" record
6) A traceback occurs

Error:- "ValueError: Expected singleton: hr.employee(1, 3)"

Because after the commit {1 }from saas-17.1 when we have multiple records for
a record in multi-companies and shift to single company,
the other company records are also accessible.

Because of that it leads to the above traceback when trying to access "id"
from "self.employee_ids"

https://github.com/odoo/odoo/blob/4f9b67938032a8b253d930a70acd2283b30ecda6/addons/hr/models/res_partner.py#L30-L36

[1] odoo@3c8e449

After applying this commit will resolve this issue by filtering the employee_ids
based on the current company record "id"

sentry-5289238474
@robodoo
Copy link
Contributor

robodoo commented May 3, 2024

@C3POdoo C3POdoo added the RD research & development, internal work label May 3, 2024
@alsh-odoo
Copy link
Contributor Author

Hello @odoo/sentry_reviewers 👋

Can I have review on this PR

Thank You 🙂

@adwid adwid requested a review from abla001 May 13, 2024 07:15
@abla001
Copy link
Contributor

abla001 commented May 13, 2024

LGTM!

@abla001 abla001 marked this pull request as ready for review May 13, 2024 07:52
@C3POdoo C3POdoo requested a review from a team May 13, 2024 07:54
@sofiagvaladze
Copy link
Contributor

robodoo r+

robodoo pushed a commit that referenced this pull request May 13, 2024
This traceback occurs when the user clicks on the employee smart button.

To reproduce this issue:-

1) Install "Employees", "contacts" without demo data
2) Enter into multi-company environment by creating  a new company
3) Now create a new employee with company as new company and
  related user in the "Hr settings" as "Administrator"
4) Now switch to single company environment
5) click on the "employee" smart button from contact module for the
  "Administrator" record
6) A traceback occurs

Error:- "ValueError: Expected singleton: hr.employee(1, 3)"

Because after the commit {1 }from saas-17.1 when we have multiple records for
a record in multi-companies and shift to single company,
the other company records are also accessible.

Because of that it leads to the above traceback when trying to access "id"
from "self.employee_ids"

https://github.com/odoo/odoo/blob/4f9b67938032a8b253d930a70acd2283b30ecda6/addons/hr/models/res_partner.py#L30-L36

[1] 3c8e449

After applying this commit will resolve this issue by filtering the employee_ids
based on the current company record "id"

sentry-5289238474

closes #164294

Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
@robodoo robodoo closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants