Skip to content
Snippets Groups Projects
Commit f53d4a28 authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[FIX] hr: add private contact to employee's followers


When creating an employee with a private contact,
the contact will not be automatically added to the employee's followers.

The desired behavior is that the contact is added
to the followers even if it has a private address.
Commit: 8760a4d0

However, this behavior will not be possible because
adding a contact with a private address is forbidden.
Commit: 20536e1b

Solution:
The solution is to use the private method `_message_subscribe`.
This is not a problem in the business case.
Indeed, the people who have access to the employee's file
also have access to the private contacts.
Moreover, the access rights of the public method `message_subscribe`
do not concern this business case.

opw-3249646

closes odoo/odoo#118779

X-original-commit: b06857afa371d2164f1f5ec402a6074a237d8230
Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent b41c76bd
No related branches found
No related tags found
No related merge requests found
......@@ -331,7 +331,6 @@ class HrEmployeePrivate(models.Model):
employees = super().create(vals_list)
if self.env.context.get('salary_simulation'):
return employees
employees.message_subscribe(employees.address_home_id.ids)
employee_departments = employees.department_id
if employee_departments:
self.env['mail.channel'].sudo().search([
......@@ -340,6 +339,7 @@ class HrEmployeePrivate(models.Model):
onboarding_notes_bodies = {}
hr_root_menu = self.env.ref('hr.menu_hr_root')
for employee in employees:
employee._message_subscribe(employee.address_home_id.ids)
# Launch onboarding plans
url = '/web#%s' % url_encode({
'action': 'hr.plan_wizard_action',
......@@ -360,7 +360,8 @@ class HrEmployeePrivate(models.Model):
if account_id:
self.env['res.partner.bank'].browse(account_id).partner_id = vals['address_home_id']
self.message_unsubscribe(self.address_home_id.ids)
self.message_subscribe([vals['address_home_id']])
if vals['address_home_id']:
self._message_subscribe([vals['address_home_id']])
if vals.get('user_id'):
# Update the profile pictures with user, except if provided
vals.update(self._sync_user(self.env['res.users'].browse(vals['user_id']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment