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.
24 lines
804 B
Python
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
|