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 = []
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):
<menuitem name="My Current Timesheet" id="menu_act_hr_timesheet_sheet_form_my_current" parent="hr_attendance.menu_hr_time_tracking" action="ir_actions_server_timsheet_sheet" sequence="1"/>
<record id="mt_submit_timesheet" model="mail.message.subtype">
- <field name="name">Timesheets to Validate</field>
+ <field name="name">Submit</field>
+ <field name="res_model">hr_timesheet_sheet.sheet</field>
+ </record>
+
+ <record id="mt_refuse_timesheet" model="mail.message.subtype">
+ <field name="name">Refuse</field>
<field name="res_model">hr_timesheet_sheet.sheet</field>
</record>
<button name="button_confirm" states="draft" string="Submit to Manager" type="object" class="oe_highlight"/>
<button name="done" states="confirm" string="Approve" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
<button name="action_set_to_draft" states="done" string="Set to Draft" type="object" />
- <button name="cancel" states="confirm" string="Refuse" type="workflow" groups="base.group_hr_user" />
+ <button name="button_cancel" states="confirm" string="Refuse" type="object" groups="base.group_hr_user" />
<field name="state" widget="statusbar" statusbar_visible="new,confirm,done"/>
</header>
<sheet>