From f4574647dd6b1497cf530d421e38df71eece2eb3 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 1 Feb 2016 11:07:10 +0100 Subject: [PATCH] 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) --- hr_holidays_usability/hr_holidays.py | 4 ++++ hr_holidays_usability/hr_holidays_mail.xml | 15 +++++++++------ .../wizard/hr_holidays_mass_allocation.py | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hr_holidays_usability/hr_holidays.py b/hr_holidays_usability/hr_holidays.py index f963d02..54888bf 100644 --- a/hr_holidays_usability/hr_holidays.py +++ b/hr_holidays_usability/hr_holidays.py @@ -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") diff --git a/hr_holidays_usability/hr_holidays_mail.xml b/hr_holidays_usability/hr_holidays_mail.xml index 49835ff..70f43e1 100644 --- a/hr_holidays_usability/hr_holidays_mail.xml +++ b/hr_holidays_usability/hr_holidays_mail.xml @@ -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) +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) code ir.actions.server @@ -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) +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) code ir.actions.server @@ -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) +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) code ir.actions.server diff --git a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py index adcc7ae..8f83e28 100644 --- a/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py +++ b/hr_holidays_usability/wizard/hr_holidays_mass_allocation.py @@ -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(