[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.
This commit is contained in:
Thibault Delavallée
2018-02-26 12:15:30 +01:00
parent 1b5b2b9dd0
commit a6c187a01c
2 changed files with 1 additions and 68 deletions
-26
View File
@@ -21,29 +21,3 @@ class User(models.Model):
employees = Employee.search([('user_id', '=', user.id)])
employees.write({'name': vals['name']})
return result
@api.multi
def _get_related_employees(self):
self.ensure_one()
ctx = dict(self.env.context)
if 'thread_model' in ctx:
ctx['thread_model'] = 'hr.employee'
return self.env['hr.employee'].with_context(ctx).search([('user_id', '=', self.id)])
@api.multi
@api.returns('self', lambda value: value.id)
def message_post(self, **kwargs):
""" Redirect the posting of message on res.users to the related employees.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id.
"""
self.ensure_one()
if kwargs.get('message_type') == 'email':
return super(User, self).message_post(**kwargs)
message_id = None
employees = self._get_related_employees()
if not employees: # no employee: fall back on previous behavior
return super(User, self).message_post(**kwargs)
for employee in employees:
message_id = employee.message_post(**kwargs)
return message_id
+1 -42
View File
@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, exceptions, fields, models, modules
from odoo.tools import pycompat
from odoo.addons.base.models.res_users import is_selection_groups
@@ -32,6 +31,7 @@ class Users(models.Model):
help="Policy on how to handle Chatter notifications:\n"
"- Handle by Emails: notifications are sent to your email address\n"
"- Handle in Odoo: notifications appear in your Odoo Inbox")
def __init__(self, pool, cr):
""" Override of __init__ to add access rights on notification_email_send
and alias fields. Access rights are disabled by default, but allowed
@@ -81,47 +81,6 @@ class Users(models.Model):
# TODO change SUPERUSER_ID into user.id but catch errors
return self.partner_id.sudo().message_post(body=body)
def _message_post_get_pid(self):
self.ensure_one()
if 'thread_model' in self.env.context:
self = self.with_context(thread_model='res.users')
return self.partner_id.id
@api.multi
@api.returns('self', lambda value: value.id)
def message_post(self, **kwargs):
""" Redirect the posting of message on res.users as a private discussion.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id. """
current_pids = []
partner_ids = kwargs.get('partner_ids', [])
user_pid = self._message_post_get_pid()
for partner_id in partner_ids:
if isinstance(partner_id, (list, tuple)) and partner_id[0] == 4 and len(partner_id) == 2:
current_pids.append(partner_id[1])
elif isinstance(partner_id, (list, tuple)) and partner_id[0] == 6 and len(partner_id) == 3:
current_pids.append(partner_id[2])
elif isinstance(partner_id, pycompat.integer_types):
current_pids.append(partner_id)
if user_pid not in current_pids:
partner_ids.append(user_pid)
kwargs['partner_ids'] = partner_ids
return self.env['mail.thread'].message_post(**kwargs)
def message_update(self, msg_dict, update_vals=None):
return True
def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None, force=True):
return True
@api.multi
def message_partner_info_from_emails(self, emails, link_mail=False):
return self.env['mail.thread'].message_partner_info_from_emails(emails, link_mail=link_mail)
@api.multi
def message_get_suggested_recipients(self):
return dict((res_id, list()) for res_id in self._ids)
@api.model
def activity_user_count(self):
query = """SELECT m.id, count(*), act.res_model as model,