Add option no_email_notification on hr_holidays, to be able to skip email notification (dirty workaround to the fact that workflow doesn't pass context)

This commit is contained in:
Alexis de Lattre
2016-02-01 11:07:10 +01:00
parent 1b2fada686
commit f4574647dd
3 changed files with 14 additions and 6 deletions

View File

@@ -218,6 +218,10 @@ class HrHolidays(models.Model):
limit = fields.Boolean( # pose des pbs de droits
related='holiday_status_id.limit', string='Allow to Override Limit',
readonly=True)
no_email_notification = fields.Boolean(
string='No Email Notification',
help="This field is designed to workaround the fact that you can't "
"pass context in the methods of the workflow")
posted_date = fields.Date(
string='Posted Date', track_visibility='onchange')
number_of_days_temp = fields.Float(string="Number of days")

View File

@@ -8,8 +8,9 @@
'wkf_tracker': 'submitted',
'dbname': cr.dbname,
})
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
@@ -22,8 +23,9 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, conte
'wkf_tracker': 'validated',
'dbname': cr.dbname,
})
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>
@@ -36,8 +38,9 @@ self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, conte
'wkf_tracker': 'refused',
'dbname': cr.dbname,
})
template_id=self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool.get('email.template').send_mail(cr, uid, template_id, object.id, context=context)</field>
if not object.no_email_notification:
template_id=self.pool['ir.model.data'].get_object_reference(cr, uid, 'hr_holidays_usability', 'email_template_hr_holidays')[1]
self.pool['email.template'].send_mail(cr, uid, template_id, object.id, context=context)</field>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="hr_holidays.model_hr_holidays"/>

View File

@@ -77,6 +77,7 @@ class HrHolidaysMassAllocation(models.TransientModel):
'type': 'add',
'holiday_type': 'employee',
'holiday_status_id': self.holiday_status_id.id,
'no_email_notification': True,
})
if auto_approve:
workflow.trg_validate(