[IMP] hr_attendance: Improve Code and clean
bzr revid: mra@mra-laptop-20100813064434-wm4lps6xx6skv2op
This commit is contained in:
parent
af20cb5b1f
commit
1250d1cac7
|
@ -30,7 +30,7 @@
|
||||||
actions(Sign in/Sign out) performed by them.
|
actions(Sign in/Sign out) performed by them.
|
||||||
""",
|
""",
|
||||||
'author': 'OpenERP SA',
|
'author': 'OpenERP SA',
|
||||||
'depends': ['base', 'hr'],
|
'depends': ['hr'],
|
||||||
'update_xml': [
|
'update_xml': [
|
||||||
'security/hr_security.xml',
|
'security/hr_security.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
|
|
@ -34,6 +34,7 @@ class hr_action_reason(osv.osv):
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'action_type': 'sign_in',
|
'action_type': 'sign_in',
|
||||||
}
|
}
|
||||||
|
|
||||||
hr_action_reason()
|
hr_action_reason()
|
||||||
|
|
||||||
def _employee_get(obj, cr, uid, context=None):
|
def _employee_get(obj, cr, uid, context=None):
|
||||||
|
@ -59,7 +60,7 @@ class hr_attendance(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.datetime('Date', required=True, select=1),
|
'name': fields.datetime('Date', required=True, select=1),
|
||||||
'action': fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out'), ('action','Action')], 'Action', required=True),
|
'action': fields.selection([('sign_in', 'Sign In'), ('sign_out', 'Sign Out'), ('action','Action')], 'Action', required=True),
|
||||||
'action_desc': fields.many2one("hr.action.reason", "Action reason", domain="[('action_type', '=', action)]", help='Specifies the reason for Signing In/Signing Out in case of extra hours.'),
|
'action_desc': fields.many2one("hr.action.reason", "Action Reason", domain="[('action_type', '=', action)]", help='Specifies the reason for Signing In/Signing Out in case of extra hours.'),
|
||||||
'employee_id': fields.many2one('hr.employee', "Employee's Name", required=True, select=True),
|
'employee_id': fields.many2one('hr.employee', "Employee's Name", required=True, select=True),
|
||||||
'day': fields.function(_day_compute, method=True, type='char', string='Day', store=True, select=1, size=32),
|
'day': fields.function(_day_compute, method=True, type='char', string='Day', store=True, select=1, size=32),
|
||||||
}
|
}
|
||||||
|
@ -86,6 +87,7 @@ class hr_attendance(osv.osv):
|
||||||
|
|
||||||
_constraints = [(_altern_si_so, 'Error: Sign in (resp. Sign out) must follow Sign out (resp. Sign in)', ['action'])]
|
_constraints = [(_altern_si_so, 'Error: Sign in (resp. Sign out) must follow Sign out (resp. Sign in)', ['action'])]
|
||||||
_order = 'name desc'
|
_order = 'name desc'
|
||||||
|
|
||||||
hr_attendance()
|
hr_attendance()
|
||||||
|
|
||||||
class hr_employee(osv.osv):
|
class hr_employee(osv.osv):
|
||||||
|
@ -144,14 +146,12 @@ class hr_employee(osv.osv):
|
||||||
raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,))
|
raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,))
|
||||||
|
|
||||||
res = {'action': type, 'employee_id': emp['id']}
|
res = {'action': type, 'employee_id': emp['id']}
|
||||||
|
|
||||||
if dt:
|
if dt:
|
||||||
res['name'] = dt
|
res['name'] = dt
|
||||||
id = obj_attendance.create(cr, uid, res, context=context)
|
id = obj_attendance.create(cr, uid, res, context=context)
|
||||||
|
|
||||||
if type != 'action':
|
if type != 'action':
|
||||||
return id
|
return id
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
hr_employee()
|
hr_employee()
|
||||||
|
|
Loading…
Reference in New Issue