From 7a8a15ddceb9192bec901929cb8ef9abc7abdd22 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 20 Nov 2012 16:50:09 +0530 Subject: [PATCH 01/12] [IMP]add function for open timesheets from employee form view bzr revid: sgo@tinyerp.com-20121120112009-3a5k48dr1otlgs1v --- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 27 ++++++++++++++++++- .../hr_timesheet_sheet_view.xml | 10 +------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index bf6790c6be3..af2f5f07179 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -220,9 +220,34 @@ class hr_timesheet_sheet(osv.osv): if employee_id: department_id = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context).department_id.id return {'value': {'department_id': department_id}} - + hr_timesheet_sheet() +class hr_employee(osv.osv): + _inherit = "hr.employee" + + def open_timesheet(self, cr, uid, ids, context=None): + if context is None: + context = {} + employee = self.browse(cr, uid, ids[0], context) + view_context = { + 'search_default_employee_id' : [employee.id], + 'default_employee_id' : employee.id, + 'default_user_id': employee.user_id.id, + } + value = { + 'name': _('Timesheets'), + 'context': view_context, + 'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'hr_timesheet_sheet.sheet', + 'view_id': False, + 'type': 'ir.actions.act_window' + } + return value + +hr_employee() + class account_analytic_line(osv.osv): _inherit = "account.analytic.line" diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 6de6be6c08d..06779e73472 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -351,21 +351,13 @@ - - hr_timesheet_sheet.sheet - form - Timesheets - tree,form - {'search_default_employee_id': [active_id], 'default_employee_id': active_id} - - hr.timesheet.sheet.employee.extd_form hr.employee -