[IMP] post to hr.employee instead of res.partners
bzr revid: mat@openerp.com-20130417094927-894k4ncuy30hngpu
This commit is contained in:
parent
8ab3e5d2a1
commit
90e349acea
|
@ -219,15 +219,18 @@ class hr_employee(osv.osv):
|
|||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
employee_id = super(hr_employee, self).create(cr, uid, data, context=context)
|
||||
employee = self.browse(cr, uid, employee_id, context=context)
|
||||
try:
|
||||
(model, mail_group_id) = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'group_all_employees')
|
||||
employee = self.browse(cr, uid, employee_id, context=context)
|
||||
self.pool.get('mail.group').message_post(cr, uid, [mail_group_id],
|
||||
body='Welcome to %s! Please help him/her take the first steps with OpenERP!' % (employee.name),
|
||||
body=_('Welcome to %s! Please help him/her take the first steps with OpenERP!') % (employee.name),
|
||||
subtype='mail.mt_comment', context=context)
|
||||
except:
|
||||
pass # group deleted: do not push a message
|
||||
|
||||
self.message_post(cr, uid, employee_id,
|
||||
body=_('%s has joined the company.') % employee.name,
|
||||
subtype='mail.mt_comment', context=context)
|
||||
return employee_id
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
<data>
|
||||
|
||||
<record id="mail.action_mail_inbox_feeds" model="ir.actions.client">
|
||||
<field name="context">{
|
||||
'default_model': 'hr.employee',
|
||||
'default_res_id': uid,
|
||||
'res_users_id': uid,
|
||||
}</field>
|
||||
<field name="params" eval=""{
|
||||
'domain': [
|
||||
('to_read', '=', True),
|
||||
|
|
|
@ -23,8 +23,6 @@ from openerp.osv import osv
|
|||
|
||||
|
||||
class mail_message(osv.Model):
|
||||
""" Messages model: system notification (replacing res.log notifications),
|
||||
comments (OpenChatter discussion) and incoming emails. """
|
||||
_name = 'mail.message'
|
||||
_inherit = 'mail.message'
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class res_users(osv.Model):
|
||||
|
@ -36,3 +37,38 @@ class res_users(osv.Model):
|
|||
"""Update display_employees_suggestions value to False"""
|
||||
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):
|
||||
"""Do not welcome new users anymore, welcome new employees instead"""
|
||||
return True
|
||||
|
||||
def _message_post_get_eid(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'] = '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
|
||||
|
||||
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. """
|
||||
employee_ids = self._message_post_get_eid(cr, uid, thread_id, context=context)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue