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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/hr/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def action_open_employees(self):
'name': _('Employee'),
'type': 'ir.actions.act_window',
'res_model': 'hr.employee',
'res_id': self.employee_ids.id,
'res_id': self.employee_ids.filtered(lambda e: e.company_id in self.env.companies).id,
'view_mode': 'form',
}
4 changes: 4 additions & 0 deletions addons/hr/tests/test_hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def test_employee_smart_button_multi_company(self):
self.assertEqual(partner.employees_count, 1)
partner.with_company(company_B)._compute_employees_count()
self.assertEqual(partner.employees_count, 1)
single_company_action = partner.with_company(company_B).action_open_employees()
self.assertEqual(single_company_action.get('view_mode'), 'form')
partner.with_company(company_A).with_company(company_B)._compute_employees_count()
self.assertEqual(partner.employees_count, 2)
multi_company_action = partner.with_company(company_A).with_company(company_B).action_open_employees()
self.assertEqual(multi_company_action.get('view_mode'), 'kanban')

def test_employee_linked_partner(self):
user_partner = self.user_without_image.partner_id
Expand Down