From 1250d1cac7d055f1a8beb891d24c39f6c0dc7ba8 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 13 Aug 2010 12:14:34 +0530 Subject: [PATCH] [IMP] hr_attendance: Improve Code and clean bzr revid: mra@mra-laptop-20100813064434-wm4lps6xx6skv2op --- addons/hr_attendance/__openerp__.py | 4 ++-- addons/hr_attendance/hr_attendance.py | 8 ++++---- addons/hr_attendance/wizard/hr_attendance_bymonth.py | 10 +++++----- addons/hr_attendance/wizard/hr_attendance_byweek.py | 10 +++++----- addons/hr_attendance/wizard/hr_attendance_error.py | 10 +++++----- .../hr_attendance/wizard/hr_attendance_sign_in_out.py | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py index 383f1dfa8b1..68eb3c20258 100644 --- a/addons/hr_attendance/__openerp__.py +++ b/addons/hr_attendance/__openerp__.py @@ -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', diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 938df72d4e9..842fe409d12 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -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: \ No newline at end of file diff --git a/addons/hr_attendance/wizard/hr_attendance_bymonth.py b/addons/hr_attendance/wizard/hr_attendance_bymonth.py index f66e7892601..8c41fefcaa6 100644 --- a/addons/hr_attendance/wizard/hr_attendance_bymonth.py +++ b/addons/hr_attendance/wizard/hr_attendance_bymonth.py @@ -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: \ No newline at end of file diff --git a/addons/hr_attendance/wizard/hr_attendance_byweek.py b/addons/hr_attendance/wizard/hr_attendance_byweek.py index 175ebf8a228..e2b071de66a 100644 --- a/addons/hr_attendance/wizard/hr_attendance_byweek.py +++ b/addons/hr_attendance/wizard/hr_attendance_byweek.py @@ -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: \ No newline at end of file diff --git a/addons/hr_attendance/wizard/hr_attendance_error.py b/addons/hr_attendance/wizard/hr_attendance_error.py index 449fc4ca5c2..24109b11496 100644 --- a/addons/hr_attendance/wizard/hr_attendance_error.py +++ b/addons/hr_attendance/wizard/hr_attendance_error.py @@ -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: \ No newline at end of file diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index 635c25940e1..09f9f9364c5 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -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: \ No newline at end of file