[IMP]add function for open timesheets from employee form view
bzr revid: sgo@tinyerp.com-20121120112009-3a5k48dr1otlgs1v
This commit is contained in:
parent
d9d127403b
commit
7a8a15ddce
|
@ -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"
|
||||
|
||||
|
|
|
@ -351,21 +351,13 @@
|
|||
|
||||
<!-- Timesheet Button on Employee Form -->
|
||||
|
||||
<record id="act_hr_employee_2_hr_timesheet" model="ir.actions.act_window">
|
||||
<field name="res_model">hr_timesheet_sheet.sheet</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="name">Timesheets</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id}</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_timesheet_sheet_employee_extd_form" model="ir.ui.view">
|
||||
<field name="name">hr.timesheet.sheet.employee.extd_form</field>
|
||||
<field name="model">hr.employee</field>
|
||||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_employee_extd_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button name="%(act_hr_employee_2_hr_timesheet)d" string="Timesheets" type="action" groups="base.group_hr_manager"/>
|
||||
<button name="open_timesheet" string="Timesheets" type="object" groups="base.group_hr_manager"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue