[FIX] hr_holidays: subscription and emails
[FIX] auto subscription - removed auto subscription of managers for leave / allocation requests as this can be managed through subscripion to the department - updated some subtype labels - removed auto subscription of leave / allocation creator as the employee is already automatically subscribed; managers creating leave and allocation in batch should not automatically follow the created records except through the department subscription [FIX] notification email batch - add a context key to use the email queue for notifications linked to allocations created in batch - also fixed a missing context in a browse
This commit is contained in:
@@ -352,7 +352,7 @@ class hr_holidays(osv.osv):
|
||||
if context is None:
|
||||
context = {}
|
||||
employee_id = values.get('employee_id', False)
|
||||
context = dict(context, mail_create_nolog=True)
|
||||
context = dict(context, mail_create_nolog=True, mail_create_nosubscribe=True)
|
||||
if not self._check_state_access_right(cr, uid, values, context):
|
||||
raise AccessError(_('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % values.get('state'))
|
||||
if not values.get('name'):
|
||||
@@ -428,7 +428,8 @@ class hr_holidays(osv.osv):
|
||||
elif record.holiday_type == 'category':
|
||||
emp_ids = obj_emp.search(cr, uid, [('category_ids', 'child_of', [record.category_id.id])])
|
||||
leave_ids = []
|
||||
for emp in obj_emp.browse(cr, uid, emp_ids):
|
||||
batch_context = dict(context, mail_notify_force_send=False)
|
||||
for emp in obj_emp.browse(cr, uid, emp_ids, context=context):
|
||||
vals = {
|
||||
'name': record.name,
|
||||
'type': record.type,
|
||||
@@ -441,7 +442,7 @@ class hr_holidays(osv.osv):
|
||||
'parent_id': record.id,
|
||||
'employee_id': emp.id
|
||||
}
|
||||
leave_ids.append(self.create(cr, uid, vals, context=None))
|
||||
leave_ids.append(self.create(cr, uid, vals, context=batch_context))
|
||||
for leave_id in leave_ids:
|
||||
# TODO is it necessary to interleave the calls?
|
||||
for sig in ('confirm', 'validate', 'second_validate'):
|
||||
@@ -449,9 +450,6 @@ 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.employee_id and record.employee_id.parent_id and record.employee_id.parent_id.user_id:
|
||||
self.message_subscribe_users(cr, uid, [record.id], user_ids=[record.employee_id.parent_id.user_id.id], context=context)
|
||||
return self.write(cr, uid, ids, {'state': 'confirm'})
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
<!-- Department related subtypes for messaging / Chatter -->
|
||||
<record id="mt_department_holidays_confirmed" model="mail.message.subtype">
|
||||
<field name="name">Leaves/Allocations: first approval</field>
|
||||
<field name="name">Leaves/Allocations Confirmed</field>
|
||||
<field name="res_model">hr.department</field>
|
||||
<field name="default" eval="True"/>
|
||||
<field name="parent_id" eval="ref('mt_holidays_confirmed')"/>
|
||||
@@ -76,7 +76,7 @@
|
||||
<field name="sequence" eval="6"/>
|
||||
</record>
|
||||
<record id="mt_department_holidays_first_validated" model="mail.message.subtype">
|
||||
<field name="name">Leaves/Allocations: second approval</field>
|
||||
<field name="name">Leaves/Allocations First Approval</field>
|
||||
<field name="res_model">hr.department</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="parent_id" eval="ref('mt_holidays_first_validated')"/>
|
||||
|
||||
Reference in New Issue
Block a user