[IMP] [CLEAN] [REF] mail, res_partner, res_users, hr: cleaned partner / employee profile following last specifications.

Partner profile is now classic, no more email-routing.
Writing on res.users, basically, begins a private discussion.
With HR, emails on res.users are private discussions, other
are post on employee profile.
Some cleaning in Chatter about Followers of ... , now talking about
partner or employee profile.

bzr revid: tde@openerp.com-20130515153159-cm52byvb7w6m1sxs
This commit is contained in:
Thibault Delavallée
2013-05-15 17:31:59 +02:00
parent 8d312b85ba
commit 89896f32bb
6 changed files with 37 additions and 68 deletions
+8 -17
View File
@@ -19,7 +19,7 @@ class res_users(osv.Model):
}
def __init__(self, pool, cr):
""" Override of __init__ to add access rights on
""" Override of __init__ to add access rights on
display_employees_suggestions fields. Access rights are disabled by
default, but allowed on some specific fields defined in
self.SELF_{READ/WRITE}ABLE_FIELDS.
@@ -35,7 +35,8 @@ class res_users(osv.Model):
def stop_showing_employees_suggestions(self, cr, uid, user_id, context=None):
"""Update display_employees_suggestions value to False"""
if context is None: context = {}
if context is None:
context = {}
self.write(cr, uid, user_id, {"display_employees_suggestions": False}, context)
def _create_welcome_message(self, cr, uid, user, context=None):
@@ -48,27 +49,17 @@ class res_users(osv.Model):
context['thread_model'] = 'hr.employee'
if isinstance(thread_id, (list, tuple)):
thread_id = thread_id[0]
employee_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', thread_id)], context=context)
assert employee_ids, "Can not post message to res.users not linked to employee"
return employee_ids
return self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', thread_id)], context=context)
def message_post(self, cr, uid, thread_id, context=None, **kwargs):
""" Redirect the posting of message on res.users to the related employee.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id. """
if kwargs.get('type') == 'email':
return super(res_users, self).message_post(cr, uid, thread_id, context=context, **kwargs)
employee_ids = self._message_post_get_eid(cr, uid, thread_id, context=context)
if not employee_ids:
pass # dpo something
for employee_id in employee_ids:
res = self.pool.get('hr.employee').message_post(cr, uid, employee_id, context=context, **kwargs)
return res
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
for id in ids:
employee_ids = self._message_post_get_eid(cr, uid, id, context=context)
res = self.pool.get('hr.employee').message_update(cr, uid, employee_ids, msg_dict, update_vals=update_vals, context=context)
return res
def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None):
for id in ids:
employee_ids = self._message_post_get_eid(cr, uid, id, context=context)
res = self.pool.get('hr.employee').message_subscribe(cr, uid, employee_ids, partner_ids, subtype_ids=subtype_ids, context=context)
return res
+3 -1
View File
@@ -202,8 +202,10 @@ class mail_mail(osv.Model):
:param browse_record mail: mail.mail browse_record
:param browse_record partner: specific recipient partner
"""
if force or (not mail.subject and mail.model and mail.res_id):
if (force or not mail.subject) and mail.record_name:
return 'Re: %s' % (mail.record_name)
elif (force or not mail.subject) and mail.parent_id and mail.parent_id.subject:
return 'Re: %s' % (mail.parent_id.subject)
return mail.subject
def send_get_mail_body_footer(self, cr, uid, mail, partner=None, context=None):
+1 -17
View File
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.tools.translate import _
from openerp.osv import fields, osv
@@ -52,21 +53,4 @@ class res_partner_mail(osv.Model):
self._message_add_suggested_recipient(cr, uid, recipients, partner, partner=partner, reason=_('Partner Profile'))
return recipients
def message_post(self, cr, uid, thread_id, **kwargs):
""" Override related to res.partner. In case of email message, set it as
private:
- add the target partner in the message partner_ids
- set thread_id as None, because this will trigger the 'private'
aspect of the message (model=False, res_id=False)
"""
if isinstance(thread_id, (list, tuple)):
thread_id = thread_id[0]
if kwargs.get('type') == 'email':
partner_ids = kwargs.get('partner_ids', [])
if thread_id not in [command[1] for command in partner_ids]:
partner_ids.append((4, thread_id))
kwargs['partner_ids'] = partner_ids
thread_id = False
return super(res_partner_mail, self).message_post(cr, uid, thread_id, **kwargs)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+12 -29
View File
@@ -112,7 +112,7 @@ class res_users(osv.Model):
def _message_post_get_pid(self, cr, uid, thread_id, context=None):
assert thread_id, "res.users does not support posting global messages"
if context and 'thread_model' in context:
context['thread_model'] = 'res.partner'
context['thread_model'] = 'res.users'
if isinstance(thread_id, (list, tuple)):
thread_id = thread_id[0]
return self.browse(cr, SUPERUSER_ID, thread_id).partner_id.id
@@ -121,48 +121,31 @@ class res_users(osv.Model):
""" Redirect the posting of message on res.users to the related partner.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id. """
if isinstance(thread_id, (list, tuple)):
thread_id = thread_id[0]
partner_ids = kwargs.get('partner_ids', [])
partner_id = self._message_post_get_pid(cr, uid, thread_id, context=context)
return self.pool.get('res.partner').message_post(cr, uid, partner_id, context=context, **kwargs)
if partner_id not in [command[1] for command in partner_ids]:
partner_ids.append(partner_id)
kwargs['partner_ids'] = partner_ids
return self.pool.get('mail.thread').message_post(cr, uid, False, **kwargs)
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
for id in ids:
partner_id = self.browse(cr, SUPERUSER_ID, id).partner_id.id
self.pool.get('res.partner').message_update(cr, uid, [partner_id], msg_dict, update_vals=update_vals, context=context)
return True
def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None):
for id in ids:
partner_id = self.browse(cr, SUPERUSER_ID, id).partner_id.id
self.pool.get('res.partner').message_subscribe(cr, uid, [partner_id], partner_ids, subtype_ids=subtype_ids, context=context)
return True
def message_get_partner_info_from_emails(self, cr, uid, emails, link_mail=False, context=None):
return self.pool.get('res.partner').message_get_partner_info_from_emails(cr, uid, emails, link_mail=link_mail, context=context)
return self.pool.get('mail.thread').message_get_partner_info_from_emails(cr, uid, emails, link_mail=link_mail, context=context)
def message_get_suggested_recipients(self, cr, uid, ids, context=None):
partner_ids = []
for id in ids:
partner_ids.append(self.browse(cr, SUPERUSER_ID, id).partner_id.id)
return self.pool.get('res.partner').message_get_suggested_recipients(cr, uid, partner_ids, context=context)
#------------------------------------------------------
# Compatibility methods: do not use
# TDE TODO: remove me in 8.0
#------------------------------------------------------
def message_post_user_api(self, cr, uid, thread_id, context=None, **kwargs):
""" Redirect the posting of message on res.users to the related partner.
This is done because when giving the context of Chatter on the
various mailboxes, we do not have access to the current partner_id. """
partner_id = self._message_post_get_pid(cr, uid, thread_id, context=context)
return self.pool.get('res.partner').message_post_user_api(cr, uid, partner_id, context=context, **kwargs)
def message_create_partners_from_emails(self, cr, uid, emails, context=None):
return self.pool.get('res.partner').message_create_partners_from_emails(cr, uid, emails, context=context)
return dict.fromkeys(ids, list())
def stop_showing_groups_suggestions(self, cr, uid, user_id, context=None):
"""Update display_groups_suggestions value to False"""
if context is None: context = {}
if context is None:
context = {}
self.write(cr, uid, user_id, {"display_groups_suggestions": False}, context)
+8 -1
View File
@@ -236,8 +236,15 @@ openerp.mail = function (session) {
this.format_data();
// update record_name: Partner profile
if (this.model == 'res.partner') {
this.record_name = 'Partner Profile of ' + this.record_name;
}
else if (this.model == 'hr.employee') {
this.record_name = 'News from ' + this.record_name;
}
// record options and data
this.show_record_name = this.options.show_record_name && this.record_name && !this.thread_level && this.model != 'res.partner';
this.show_record_name = this.options.show_record_name && this.record_name && !this.thread_level;
this.options.show_read = false;
this.options.show_unread = false;
if (this.options.show_read_unread_button) {
+5 -3
View File
@@ -121,9 +121,11 @@
To:
<t t-if="!widget.is_private">
<span class="oe_all_follower">
Followers of
<t t-if="widget.parent_thread.parent_message.record_name" t-raw="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'"/>
<t t-if="!widget.parent_thread.parent_message.record_name">this document</t>
<t t-if="widget.parent_thread.parent_message.record_name" t-raw="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'">
Followers of <t t-raw="'&quot;' + widget.parent_thread.parent_message.record_name + '&quot;'"/>
</t>
<t t-if="!widget.parent_thread.parent_message.record_name and widget.options.view_inbox">My Followers</t>
<t t-if="!widget.parent_thread.parent_message.record_name and !widget.options.view_inbox">Followers of this document</t>
</span>
</t>
<t t-if="!widget.is_private and (widget.partner_ids.length or (widget.author_id and widget.author_id[0]))"> and </t>