summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2015-10-23 14:36:50 +0200
committerThibault Delavallée <tde@openerp.com>2015-10-26 10:54:20 +0100
commit2be1dfc1ed7c9814cd3dbf4eb4cc95f842f738c2 (patch)
tree39dc4fc5615cd5fb4ce954622162265c5d7a0b51
parent9b385078b2aadc377aa741ef7104c6631f2a05bd (diff)
[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
-rw-r--r--addons/hr_holidays/hr_holidays.py10
-rw-r--r--addons/hr_holidays/hr_holidays_data.xml4
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 @@
<!-- 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')"/>