[MERGE] merged the branch of Guewen Baconnier (Camptocamp) that improves the hr_timesheet_sheet by allowing to make 'sign in' ('sign out') when still present (absent). Thanks for the contribution, c2c
bzr revid: qdp-launchpad@openerp.com-20111028115717-inwoqbaej5i4l549
This commit is contained in:
commit
32c21e1ac0
|
@ -33,14 +33,14 @@ class hr_si_so_ask(osv.osv_memory):
|
|||
}
|
||||
|
||||
def _get_empname(self, cr, uid, context=None):
|
||||
emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
|
||||
if emp_id:
|
||||
employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0].name
|
||||
return employee
|
||||
return ''
|
||||
|
||||
def _get_empid(self, cr, uid, context=None):
|
||||
emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
|
||||
if emp_id:
|
||||
return emp_id[0]
|
||||
return False
|
||||
|
@ -63,7 +63,6 @@ class hr_si_so_ask(osv.osv_memory):
|
|||
hr_si_so_ask()
|
||||
|
||||
class hr_sign_in_out(osv.osv_memory):
|
||||
|
||||
_name = 'hr.sign.in.out'
|
||||
_description = 'Sign In Sign Out'
|
||||
|
||||
|
@ -74,7 +73,7 @@ class hr_sign_in_out(osv.osv_memory):
|
|||
}
|
||||
|
||||
def _get_empid(self, cr, uid, context=None):
|
||||
emp_id = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
|
||||
if emp_id:
|
||||
employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0]
|
||||
return {'name': employee.name, 'state': employee.state, 'emp_id': emp_id[0]}
|
||||
|
@ -109,6 +108,7 @@ class hr_sign_in_out(osv.osv_memory):
|
|||
'res_model': 'hr.sign.in.out.ask',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'context': context,
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ class hr_sign_in_out(osv.osv_memory):
|
|||
'res_model': 'hr.sign.in.out',
|
||||
'views': [(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'context': context,
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
|
|
|
@ -226,23 +226,31 @@ class hr_timesheet_sheet(osv.osv):
|
|||
self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context)
|
||||
return True
|
||||
|
||||
def sign(self, cr, uid, ids, typ, context=None):
|
||||
emp_obj = self.pool.get('hr.employee')
|
||||
def check_sign(self, cr, uid, ids, typ, context=None):
|
||||
sheet = self.browse(cr, uid, ids, context=context)[0]
|
||||
if context is None:
|
||||
context = {}
|
||||
if not sheet.date_current == time.strftime('%Y-%m-%d'):
|
||||
raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from an other date than today'))
|
||||
emp_id = sheet.employee_id.id
|
||||
context['sheet_id']=ids[0]
|
||||
emp_obj.attendance_action_change(cr, uid, [emp_id], type=typ, context=context,)
|
||||
return True
|
||||
|
||||
def sign(self, cr, uid, ids, typ, context=None):
|
||||
self.check_sign(cr, uid, ids, typ, context=context)
|
||||
sign_obj = self.pool.get('hr.sign.in.out')
|
||||
sheet = self.browse(cr, uid, ids, context=context)[0]
|
||||
context['emp_id'] = [sheet.employee_id.id]
|
||||
sign_id = sign_obj.create(cr, uid, {}, context=context)
|
||||
methods = {'sign_in': sign_obj.si_check,
|
||||
'sign_out': sign_obj.so_check}
|
||||
wizard_result = methods[typ](cr, uid, [sign_id], context=context)
|
||||
if wizard_result.get('type', False) == 'ir.actions.act_window_close':
|
||||
return True # ensure we do not close the main window !
|
||||
wizard_result['nodestroy'] = True # do not destroy the main window !
|
||||
return wizard_result
|
||||
|
||||
def sign_in(self, cr, uid, ids, context=None):
|
||||
return self.sign(cr,uid,ids,'sign_in',context=None)
|
||||
return self.sign(cr, uid, ids, 'sign_in', context=context)
|
||||
|
||||
def sign_out(self, cr, uid, ids, context=None):
|
||||
return self.sign(cr,uid,ids,'sign_out',context=None)
|
||||
return self.sign(cr, uid, ids, 'sign_out', context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Note', size=64, select=1,
|
||||
|
@ -267,7 +275,7 @@ class hr_timesheet_sheet(osv.osv):
|
|||
help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed timesheet. \
|
||||
\n* The \'Confirmed\' state is used for to confirm the timesheet by user. \
|
||||
\n* The \'Done\' state is used when users timesheet is accepted by his/her senior.'),
|
||||
'state_attendance' : fields.related('employee_id', 'state', type='selection', selection=[('absent', 'Absent'), ('present', 'Present')], string='Current Status'),
|
||||
'state_attendance' : fields.related('employee_id', 'state', type='selection', selection=[('absent', 'Absent'), ('present', 'Present')], string='Current Status', readonly=True),
|
||||
'total_attendance_day': fields.function(_total_day, string='Total Attendance', multi="_total_day"),
|
||||
'total_timesheet_day': fields.function(_total_day, string='Total Timesheet', multi="_total_day"),
|
||||
'total_difference_day': fields.function(_total_day, string='Difference', multi="_total_day"),
|
||||
|
|
|
@ -90,10 +90,10 @@
|
|||
</tree>
|
||||
</field>
|
||||
<group col="4" colspan="1">
|
||||
<field name="state_attendance"/>
|
||||
<button name="sign_in" string="Sign In" type="object" icon="terp-gtk-jump-to-ltr" attrs="{'invisible':[('state_attendance','<>','absent')]}"/>
|
||||
<button name="sign_out" string="Sign Out" type="object" icon="terp-gtk-jump-to-rtl" attrs="{'invisible':[('state_attendance','<>','present')]}"/>
|
||||
<field name="total_attendance_day" widget="float_time" colspan="4"/>
|
||||
<field name="state_attendance"/>
|
||||
<button name="sign_in" string="Sign In" type="object" icon="terp-gtk-jump-to-ltr"/>
|
||||
<button name="sign_out" string="Sign Out" type="object" icon="terp-gtk-jump-to-rtl"/>
|
||||
<field name="total_attendance_day" widget="float_time" colspan="4"/>
|
||||
</group>
|
||||
<field colspan="4" context="{'date':date_current,'user_id':user_id}" domain="[('name','=',date_current)]" name="timesheet_ids" nolabel="1">
|
||||
<tree editable="top" string="Timesheet Lines">
|
||||
|
|
Loading…
Reference in New Issue