[IMP] hr_attendance: Improve Code and clean
bzr revid: mra@mra-laptop-20100813064434-wm4lps6xx6skv2op
This commit is contained in:
parent
af20cb5b1f
commit
1250d1cac7
|
@ -30,10 +30,10 @@
|
|||
actions(Sign in/Sign out) performed by them.
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['base', 'hr'],
|
||||
'depends': ['hr'],
|
||||
'update_xml': [
|
||||
'security/hr_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/ir.model.access.csv',
|
||||
'hr_attendance_view.xml',
|
||||
'hr_attendance_wizard.xml',
|
||||
'hr_attendance_report.xml',
|
||||
|
|
|
@ -34,6 +34,7 @@ class hr_action_reason(osv.osv):
|
|||
_defaults = {
|
||||
'action_type': 'sign_in',
|
||||
}
|
||||
|
||||
hr_action_reason()
|
||||
|
||||
def _employee_get(obj, cr, uid, context=None):
|
||||
|
@ -59,7 +60,7 @@ class hr_attendance(osv.osv):
|
|||
_columns = {
|
||||
'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_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),
|
||||
'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'])]
|
||||
_order = 'name desc'
|
||||
|
||||
hr_attendance()
|
||||
|
||||
class hr_employee(osv.osv):
|
||||
|
@ -144,16 +146,14 @@ 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,))
|
||||
|
||||
res = {'action': type, 'employee_id': emp['id']}
|
||||
|
||||
if dt:
|
||||
res['name'] = dt
|
||||
id = obj_attendance.create(cr, uid, res, context=context)
|
||||
|
||||
if type != 'action':
|
||||
return id
|
||||
|
||||
return True
|
||||
|
||||
hr_employee()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -29,11 +29,11 @@ class hr_attendance_bymonth(osv.osv_memory):
|
|||
_columns = {
|
||||
'month': fields.selection([(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')], 'Month', required=True),
|
||||
'year': fields.integer('Year', required=True)
|
||||
}
|
||||
}
|
||||
_defaults = {
|
||||
'month': time.gmtime()[1],
|
||||
'year': time.gmtime()[0],
|
||||
}
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
@ -42,13 +42,13 @@ class hr_attendance_bymonth(osv.osv_memory):
|
|||
'ids': [],
|
||||
'model': 'hr.employee',
|
||||
'form': self.read(cr, uid, ids)[0]
|
||||
}
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'hr.attendance.bymonth',
|
||||
'datas': datas,
|
||||
}
|
||||
}
|
||||
|
||||
hr_attendance_bymonth()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -28,11 +28,11 @@ class hr_attendance_byweek(osv.osv_memory):
|
|||
_columns = {
|
||||
'init_date': fields.date('Starting Date', required=True),
|
||||
'end_date': fields.date('Ending Date', required=True)
|
||||
}
|
||||
}
|
||||
_defaults = {
|
||||
'init_date': time.strftime('%Y-%m-%d'),
|
||||
'end_date': time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
@ -41,12 +41,12 @@ class hr_attendance_byweek(osv.osv_memory):
|
|||
'ids': [],
|
||||
'model': 'hr.employee',
|
||||
'form': self.read(cr, uid, ids)[0]
|
||||
}
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'hr.attendance.allweeks',
|
||||
'datas': datas,
|
||||
}
|
||||
}
|
||||
hr_attendance_byweek()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -31,12 +31,12 @@ class hr_attendance_error(osv.osv_memory):
|
|||
'init_date': fields.date('Starting Date', required=True),
|
||||
'end_date': fields.date('Ending Date', required=True),
|
||||
'max_delay': fields.integer('Max. Delay (Min)', required=True)
|
||||
}
|
||||
}
|
||||
_defaults = {
|
||||
'init_date': time.strftime('%Y-%m-%d'),
|
||||
'end_date': time.strftime('%Y-%m-%d'),
|
||||
'max_delay': 120,
|
||||
}
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
@ -59,13 +59,13 @@ class hr_attendance_error(osv.osv_memory):
|
|||
'ids': [],
|
||||
'model': 'hr.employee',
|
||||
'form': data_error
|
||||
}
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'hr.attendance.error',
|
||||
'datas': datas,
|
||||
}
|
||||
}
|
||||
|
||||
hr_attendance_error()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -192,4 +192,4 @@ class hr_sign_in_out(osv.osv_memory):
|
|||
|
||||
hr_sign_in_out()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue