diff --git a/addons/hr/res_users.py b/addons/hr/res_users.py index ce2b2698478..c3550596281 100644 --- a/addons/hr/res_users.py +++ b/addons/hr/res_users.py @@ -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 diff --git a/addons/mail/mail_mail.py b/addons/mail/mail_mail.py index 3c30a950230..95fbac478d6 100644 --- a/addons/mail/mail_mail.py +++ b/addons/mail/mail_mail.py @@ -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): diff --git a/addons/mail/res_partner.py b/addons/mail/res_partner.py index 8527e60aba0..8da2441f3bc 100644 --- a/addons/mail/res_partner.py +++ b/addons/mail/res_partner.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + 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: diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 30a5d2e997d..b9883489ca6 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -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) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index b8720e8f1c7..3338954d417 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -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) { diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index d0f975e84d7..1ee1af68fff 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -121,9 +121,11 @@ To: - Followers of - - this document + + Followers of + + My Followers + Followers of this document and