[IMP] post welcome employee message only if employee created from applicant.
bzr revid: tpa@tinyerp.com-20131223102329-147mo4x9o1mc59lq
This commit is contained in:
parent
e453001a7f
commit
50d67b6461
|
@ -229,29 +229,6 @@ class hr_employee(osv.osv):
|
|||
'color': 0,
|
||||
}
|
||||
|
||||
def create(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
create_ctx = dict(context, mail_create_nolog=True)
|
||||
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
|
||||
# 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],
|
||||
body=_('Welcome to %s! Please help him/her take the first steps with OpenERP!') % (employee.name),
|
||||
partner_ids=partner_ids,
|
||||
subtype='mail.mt_comment', context=context
|
||||
)
|
||||
return employee_id
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
resource_ids = []
|
||||
for employee in self.browse(cr, uid, ids, context=context):
|
||||
|
|
|
@ -437,6 +437,7 @@ class hr_applicant(osv.Model):
|
|||
hr_employee = self.pool.get('hr.employee')
|
||||
model_data = self.pool.get('ir.model.data')
|
||||
act_window = self.pool.get('ir.actions.act_window')
|
||||
res_users = self.pool['res.users']
|
||||
emp_id = False
|
||||
for applicant in self.browse(cr, uid, ids, context=context):
|
||||
address_id = contact_name = False
|
||||
|
@ -453,6 +454,21 @@ class hr_applicant(osv.Model):
|
|||
'work_email': applicant.department_id and applicant.department_id.company_id and applicant.department_id.company_id.email or False,
|
||||
'work_phone': applicant.department_id and applicant.department_id.company_id and applicant.department_id.company_id.phone or False,
|
||||
})
|
||||
partner_ids = []
|
||||
create_ctx = dict(context, mail_create_nolog=True)
|
||||
employee = hr_employee.browse(cr, uid, emp_id, context=context)
|
||||
if employee.user_id:
|
||||
# send a copy to every user of the company
|
||||
# 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)], context=context)
|
||||
partner_ids = list(set(u.partner_id.id for u in res_users.browse(cr, uid, user_ids, context=context)))
|
||||
hr_employee.message_post(cr, uid, [emp_id],
|
||||
body=_('Welcome to %s! Please help him/her take the first steps with OpenERP!') % (employee.name),
|
||||
partner_ids=partner_ids,
|
||||
subtype='mail.mt_comment', context=context
|
||||
)
|
||||
self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context)
|
||||
else:
|
||||
raise osv.except_osv(_('Warning!'), _('You must define an Applied Job and a Contact Name for this applicant.'))
|
||||
|
|
Loading…
Reference in New Issue