Skip to content
Snippets Groups Projects
Commit 341d9317 authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[FIX] hr_holidays: mail notification on leave request confirm

The followers of the departments subscribed to the
`Leaves/Allocations Confirmed` are supposed to
receive a mail notification when an employee
confirms a leave request.

It was no longer the case since the below revision:
2be1dfc1

This revision subscribes the followers of the department
following the `confirmed` subtype manually
,on the leave request confirmation, because
`message_auto_subscribe` only works on fields for which
the value is passed to the `create` or `write` methods,
it doesn't work for related/computed fields
This can be removed as soon as `department_id` on `hr.holidays` becomes a regular
fields or as soon as `message_auto_subscribe` works with related/computed fields.

opw-676521
parent 822966d2
No related branches found
No related tags found
No related merge requests found
......@@ -450,6 +450,19 @@ class hr_holidays(osv.osv):
return True
def holidays_confirm(self, cr, uid, ids, context=None):
for record in self.browse(cr, uid, ids, context=context):
if record.department_id:
# Subscribe the followers of the department following the `confirmed` subtype
# It's done manually because `message_auto_subscribe` only works on fields for which
# the value is passed to the `create` or `write` methods,
# it doesn't work for related/computed fields
# This can be removed as soon as `department_id` on `hr.holidays` becomes a regular
# fields or as soon as `message_auto_subscribe` works with related/computed fields.
confirmed_subtype = self.pool['ir.model.data'].xmlid_to_object(cr, uid, 'hr_holidays.mt_department_holidays_confirmed', context=context)
self.message_subscribe(cr, uid, [record.id], [
follower.partner_id.id for follower in record.department_id.message_follower_ids
if confirmed_subtype in follower.subtype_ids
], context=context)
return self.write(cr, uid, ids, {'state': 'confirm'})
def holidays_refuse(self, cr, uid, ids, context=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment