[IMP] hr: synchonize image_1920 depending on self edit setting

Currenty if the self edit setting is deactivated, a user has to be
hr_user in order to change its employee image through the employee
profile.
The problem is that if the image on the employee is currently
not set, we should copy it through the employee profile whatever the
setting value

closes odoo/odoo#35542

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
RomainLibert
2019-08-13 12:50:21 +00:00
committed by Yannick Tivisse
parent 67e3924bfe
commit 1ca4c49ca1
+9 -1
View File
@@ -163,7 +163,15 @@ class User(models.Model):
if employee_values:
if 'email' in employee_values:
employee_values['work_email'] = employee_values.pop('email')
self.env['hr.employee'].sudo().search([('user_id', 'in', self.ids)]).write(employee_values)
if 'image_1920' in vals:
without_image = self.env['hr.employee'].sudo().search([('user_id', 'in', self.ids), ('image_1920', '=', False)])
with_image = self.env['hr.employee'].sudo().search([('user_id', 'in', self.ids), ('image_1920', '!=', False)])
without_image.write(employee_values)
if not can_edit_self:
employee_values.pop('image_1920')
with_image.write(employee_values)
else:
self.env['hr.employee'].sudo().search([('user_id', 'in', self.ids)]).write(employee_values)
return result
@api.model