bzr revid: fp@tinyerp.com-20110924115332-2fongn5bwx39xrv7
This commit is contained in:
Fabien Pinckaers 2011-09-24 13:53:32 +02:00
commit 18804364e5
2 changed files with 9 additions and 3 deletions

View File

@ -321,10 +321,10 @@ class hr_timesheet_sheet(osv.osv):
return time.strftime('%Y-12-31')
return time.strftime('%Y-%m-%d')
def _default_employee(self,cr, uid, context=None):
def _default_employee(self, cr, uid, context=None):
emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)], context=context)
return emp_ids and emp_ids[0] or False
_defaults = {
'date_from' : _default_date_from,
'date_current' : lambda *a: time.strftime('%Y-%m-%d'),
@ -382,6 +382,12 @@ class hr_timesheet_sheet(osv.osv):
raise osv.except_osv(_('Invalid action !'), _('You cannot delete a timesheet which have attendance entries!'))
return super(hr_timesheet_sheet, self).unlink(cr, uid, ids, context=context)
def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
department_id = False
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()

View File

@ -62,7 +62,7 @@
<field name="arch" type="xml">
<form string="Timesheet">
<group colspan="4" col="6">
<field name="employee_id"/>
<field name="employee_id" on_change="onchange_employee_id(employee_id)"/>
<field name="user_id" invisible="1"/>
<field name="date_from"/>
<field name="date_to"/>