From cd4899aa6a866ad8041f39b1626adf264e75bae1 Mon Sep 17 00:00:00 2001 From: Tejas Tank Date: Thu, 22 Nov 2012 16:30:15 +0530 Subject: [PATCH] An employee should receive a mail.message in inbox when an manager refuse a timesheet. bzr revid: tta@openerp.com-20121122110015-61xx09vchksen6v3 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 14 ++++++++++++++ .../hr_timesheet_sheet/hr_timesheet_sheet_data.xml | 7 ++++++- .../hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 15eb6d35438..36b76c0970c 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -100,6 +100,15 @@ class hr_timesheet_sheet(osv.osv): raise osv.except_osv(_('Warning!'), _('Please verify that the total difference of the sheet is lower than %.2f.') %(di,)) return True + def button_cancel(self, cr, uid, ids, context=None): + for sheet in self.browse(cr, uid, ids, context=context): + if sheet.employee_id and sheet.employee_id.user_id: + self.message_subscribe_users(cr, uid, [sheet.id], user_ids=[sheet.employee_id.user_id.id], context=context) + wf_service = netsvc.LocalService("workflow") + wf_service.trg_validate(uid, 'hr_timesheet_sheet.sheet', sheet.id, 'cancel', cr) + self.cancel_send_note(cr, uid, ids, context=context) + return True + def attendance_action_change(self, cr, uid, ids, context=None): hr_employee = self.pool.get('hr.employee') employee_ids = [] @@ -237,6 +246,11 @@ class hr_timesheet_sheet(osv.osv): for obj in self.browse(cr, uid, ids, context=context): self.message_post(cr, uid, [obj.id], body=_("Timesheet has been submitted by %s.") % (obj.employee_id.name), subtype="hr_timesheet_sheet.mt_submit_timesheet", context=context) + def cancel_send_note(self, cr, uid, ids, context=None): + user_name = self.pool.get("res.users").browse(cr, uid, uid, context=context).name + for obj in self.browse(cr, uid, ids, context=context): + self.message_post(cr, uid, [obj.id], body=_("Timesheet has been refused by %s.") % (user_name), subtype="hr_timesheet_sheet.mt_refuse_timesheet", context=context) + hr_timesheet_sheet() class account_analytic_line(osv.osv): diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml index 0f081a38bca..84d85c4202c 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml @@ -24,7 +24,12 @@ - Timesheets to Validate + Submit + hr_timesheet_sheet.sheet + + + + Refuse hr_timesheet_sheet.sheet diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 6de6be6c08d..a78ab4b61b6 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -66,7 +66,7 @@