From 2be1dfc1ed7c9814cd3dbf4eb4cc95f842f738c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 23 Oct 2015 14:36:50 +0200 Subject: [PATCH] [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 --- addons/hr_holidays/hr_holidays.py | 10 ++++------ addons/hr_holidays/hr_holidays_data.xml | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 23144e8776a..3408778a940 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -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): diff --git a/addons/hr_holidays/hr_holidays_data.xml b/addons/hr_holidays/hr_holidays_data.xml index 1e60c805c83..9f2350d970f 100644 --- a/addons/hr_holidays/hr_holidays_data.xml +++ b/addons/hr_holidays/hr_holidays_data.xml @@ -68,7 +68,7 @@ - Leaves/Allocations: first approval + Leaves/Allocations Confirmed hr.department @@ -76,7 +76,7 @@ - Leaves/Allocations: second approval + Leaves/Allocations First Approval hr.department