From b1c221e9c48edba65801c71933aeeb0e38c480ff Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 23 Oct 2013 17:53:40 +0200 Subject: [PATCH] [FIX] hr: notification about new employee joining should only be sent to employees (base.group_user) In the future we should directly use the `Whole Company` mail.group, but this does not work well enough now, as recipients will not be able to directly go to the employee record (e.g. to follow her) bzr revid: odo@openerp.com-20131023155340-z2e78xo3vb7yq008 --- addons/hr/hr.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index d19f1f7de8b..7eb601deb41 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -236,11 +236,13 @@ class hr_employee(osv.osv): employee_id = super(hr_employee, self).create(cr, uid, data, context=create_ctx) employee = self.browse(cr, uid, employee_id, context=context) if employee.user_id: + res_users = self.pool['res.users'] # send a copy to every user of the company - company_id = employee.user_id.partner_id.company_id.id - partner_ids = self.pool.get('res.partner').search(cr, uid, [ - ('company_id', '=', company_id), - ('user_ids', '!=', False)], context=context) + # TODO: post to the `Whole Company` mail.group when we'll be able to link to the employee record + _model, group_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base', 'group_user') + user_ids = res_users.search(cr, uid, [('company_id', '=', employee.user_id.company_id.id), + ('groups_id', 'in', group_id)]) + partner_ids = list(set(u.partner_id.id for u in res_users.browse(cr, uid, user_ids, context=context))) else: partner_ids = [] self.message_post(cr, uid, [employee_id],