Files
odoo_source/addons/hr/models/res_users.py
T
Thibault Delavallée a6c187a01c [REM] mail, hr: remove old redirection when posting on users
Posting on users is not supported anymore. It was implemented in a time
we thought having a twitter-like behavior in Odoo was a good idea.
Posting on users was redirected on its related partner in mail. It was
redirected on its related employee in hr. It does not make sense anymore
as employee are records with limited access and partners used for other
purpose than discussing notably in accounting.

Now that we have chat channels it makes no sense to have this kind of
behavior still implemented. Let us remove it. No functional change
should occur with this commit.
2018-02-26 12:15:30 +01:00

24 lines
804 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, fields
from odoo import SUPERUSER_ID
class User(models.Model):
_inherit = ['res.users']
employee_ids = fields.One2many('hr.employee', 'user_id', string='Related employees')
@api.multi
def write(self, vals):
""" When renaming admin user, we want its new name propagated to its related employees """
result = super(User, self).write(vals)
Employee = self.env['hr.employee']
if vals.get('name'):
for user in self.filtered(lambda user: user.id == SUPERUSER_ID):
employees = Employee.search([('user_id', '=', user.id)])
employees.write({'name': vals['name']})
return result