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 @@
-
+