[IMP] hr_* Clean the code
authorpsi (Open ERP) <psi@tinyerp.co.in>
Thu, 26 Aug 2010 04:52:04 +0000 (10:22 +0530)
committerpsi (Open ERP) <psi@tinyerp.co.in>
Thu, 26 Aug 2010 04:52:04 +0000 (10:22 +0530)
bzr revid: psi@tinyerp.co.in-20100826045204-lxfawwkq2be62e8s

addons/hr/hr_department.py
addons/hr_attendance/hr_attendance.py
addons/hr_attendance/wizard/hr_attendance_error.py
addons/hr_contract/hr_contract.py
addons/hr_evaluation/hr_evaluation.py
addons/hr_expense/hr_expense.py
addons/hr_holidays/hr_holidays.py
addons/hr_holidays/wizard/hr_holidays_summary_department.py
addons/hr_holidays/wizard/hr_holidays_summary_employees.py

index 825059b..0f2c3a9 100644 (file)
@@ -119,7 +119,7 @@ class res_users(osv.osv):
         result = {}
         obj_dept = self.pool.get('hr.department')
         for user_id in ids:
-            emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)])
+            emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)], context=context)
             cr.execute('SELECT emp.department_id FROM hr_employee AS emp \
                         JOIN resource_resource AS res ON res.id = emp.resource_id \
                         JOIN hr_department as dept ON dept.id = emp.department_id \
index 842fe40..643e5d5 100644 (file)
@@ -72,13 +72,13 @@ class hr_attendance(osv.osv):
     def _altern_si_so(self, cr, uid, ids):
         for id in ids:
             sql = '''
-            select action, name
-            from hr_attendance as att
-            where employee_id = (select employee_id from hr_attendance where id=%s)
-            and action in ('sign_in','sign_out')
-            and name <= (select name from hr_attendance where id=%s)
-            order by name desc
-            limit 2 '''
+            SELECT action, name
+            FROM hr_attendance AS att
+            WHERE employee_id = (SELECT employee_id FROM hr_attendance WHERE id=%s)
+            AND action IN ('sign_in','sign_out')
+            AND name <= (SELECT name FROM hr_attendance WHERE id=%s)
+            ORDER BY name DESC
+            LIMIT 2 '''
             cr.execute(sql,(id,id))
             atts = cr.fetchall()
             if not ((len(atts)==1 and atts[0][0] == 'sign_in') or (atts[0][0] != atts[1][0] and atts[0][1] != atts[1][1])):
@@ -117,12 +117,12 @@ class hr_employee(osv.osv):
 
     _columns = {
        'state': fields.function(_state, method=True, type='selection', selection=[('absent', 'Absent'), ('present', 'Present')], string='Attendance'),
-     }
+    }
 
     def _action_check(self, cr, uid, emp_id, dt=False, context=None):
         if context is None:
             context = {}
-        cr.execute('select max(name) from hr_attendance where employee_id=%s', (emp_id,))
+        cr.execute('SELECT MAX(name) FROM hr_attendance WHERE employee_id=%s', (emp_id,))
         res = cr.fetchone()
         return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S'))))
 
index 24109b1..6c630b1 100644 (file)
@@ -45,7 +45,7 @@ class hr_attendance_error(osv.osv_memory):
         data_error = self.read(cr, uid, ids, context=context)[0]
         date_from = data_error['init_date']
         date_to = data_error['end_date']
-        cr.execute("select id from hr_attendance where employee_id IN %s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action IN %s order by name" ,(tuple(context['active_ids']), date_to, date_from, tuple(['sign_in','sign_out'])))
+        cr.execute("SELECT id FROM hr_attendance WHERE employee_id IN %s AND to_char(name,'YYYY-mm-dd')<=%s AND to_char(name,'YYYY-mm-dd')>=%s AND action IN %s ORDER BY name" ,(tuple(context['active_ids']), date_to, date_from, tuple(['sign_in','sign_out'])))
         attendance_ids = [x[0] for x in cr.fetchall()]
         if not attendance_ids:
             raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
index 1d2962a..aa04761 100644 (file)
@@ -58,10 +58,10 @@ class hr_contract_wage_type_period(osv.osv):
     _columns = {
         'name': fields.char('Period Name', size=50, required=True, select=True),
         'factor_days': fields.float('Hours in the period', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work wased on the contract of the employee')
-        }
+    }
     _defaults = {
         'factor_days': 168.0
-        }
+    }
 hr_contract_wage_type_period()
 
 #Contract wage type (hourly, daily, monthly, ...)
@@ -73,11 +73,11 @@ class hr_contract_wage_type(osv.osv):
         'period_id': fields.many2one('hr.contract.wage.type.period', 'Wage Period', required=True),
         'type': fields.selection([('gross','Gross'), ('net','Net')], 'Type', required=True),
         'factor_type': fields.float('Factor for hour cost', digits=(12,4), required=True, help='This field is used by the timesheet system to compute the price of an hour of work wased on the contract of the employee')
-        }
+    }
     _defaults = {
         'type': 'gross',
         'factor_type': 1.8
-        }
+    }
 hr_contract_wage_type()
 
 
@@ -107,10 +107,10 @@ class hr_contract(osv.osv):
         'advantages_net': fields.float('Net Advantages Value', digits=(16,2)),
         'advantages_gross': fields.float('Gross Advantages Value', digits=(16,2)),
         'notes': fields.text('Notes'),
-        }
+    }
     _defaults = {
         'date_start': time.strftime("%Y-%m-%d"),
-        }
+    }
 
 hr_contract()
 
index 0b497c4..c80c12f 100644 (file)
@@ -274,10 +274,10 @@ class survey_request(osv.osv):
     _inherit = "survey.request"
     _columns = {
         'is_evaluation': fields.boolean('Is Evaluation?'),
-        }
+    }
     _defaults = {
         'state': 'waiting_answer',
-        }
+    }
 
 survey_request()
 
index 681a06c..c581853 100644 (file)
@@ -190,7 +190,7 @@ class hr_expense_expense(osv.osv):
             invoice_obj.button_compute(cr, uid, [inv_id], {'type': 'in_invoice'}, set_total=True)
             wf_service = netsvc.LocalService("workflow")
             wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
-            
+
             self.write(cr, uid, [exp.id], {'invoice_id': inv_id, 'state': 'invoiced'})
             res = inv_id
         return res
@@ -201,7 +201,7 @@ class product_product(osv.osv):
     _inherit = "product.product"
     _columns = {
         'hr_expense_ok': fields.boolean('Can Constitute an Expense', help="Determines if the product can be visible in the list of product within a selection from an HR expense sheet line."),
-                }
+    }
 
 product_product()
 
@@ -235,7 +235,7 @@ class hr_expense_line(osv.osv):
     _defaults = {
         'unit_quantity': 1,
         'date_value': time.strftime('%Y-%m-%d'),
-        }
+    }
     _order = "sequence"
 
     def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None):
index efd5df4..b5f4534 100644 (file)
@@ -108,7 +108,7 @@ class hr_holidays_status(osv.osv):
     _defaults = {
         'color_name': 'red',
         'active': True,
-        }
+    }
 
 hr_holidays_status()
 
@@ -147,7 +147,7 @@ class hr_holidays(osv.osv):
         'category_id': fields.many2one('hr.employee.category', "Category", help='Category Of employee'),
         'holiday_type': fields.selection([('employee','By Employee'),('category','By Employee Category')], 'Holiday Type', help='By Employee: Allocation/Request for individual Employee, By Employee Category: Allocation/Request for group of employees in category'),
         'manager_id2': fields.many2one('hr.employee', 'Second Validator', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)')
-            }
+    }
 
     _defaults = {
         'employee_id': _employee_get ,
@@ -156,7 +156,7 @@ class hr_holidays(osv.osv):
         'allocation_type': 'employee',
         'user_id': lambda obj, cr, uid, context: uid,
         'holiday_type': 'employee'
-        }
+    }
 
     def _create_resource_leave(self, cr, uid, vals, context=None):
         '''This method will create entry in resource calendar leave object at the time of holidays validated '''
@@ -452,7 +452,7 @@ class resource_calendar_leaves(osv.osv):
     _description = "Leave Detail"
     _columns = {
         'holiday_id': fields.many2one("hr.holidays", "Holiday"),
-        }
+    }
 
 resource_calendar_leaves()
 
index a08354f..06651e1 100644 (file)
@@ -31,12 +31,12 @@ class hr_holidays_summary_dept(osv.osv_memory):
         'date_from': fields.date('From', required=True),
         'depts': fields.many2many('hr.department', 'summary_dept_rel', 'sum_id', 'dept_id', 'Department(s)'),
         'holiday_type': fields.selection([('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')], 'Select Holiday Type', required=True)
-        }
+    }
 
     _defaults = {
          'date_from': time.strftime('%Y-%m-%d'),
          'holiday_type': 'Validated'
-        }
+    }
 
     def print_report(self, cr, uid, ids, context=None):
         if context is None:
@@ -48,7 +48,7 @@ class hr_holidays_summary_dept(osv.osv_memory):
              'ids': [],
              'model': 'ir.ui.menu',
              'form': data
-                 }
+            }
         return {
             'type': 'ir.actions.report.xml',
             'report_name': 'holidays.summary',
index ca9ccc8..379ff7d 100644 (file)
@@ -30,12 +30,12 @@ class hr_holidays_summary_employee(osv.osv_memory):
         'date_from': fields.date('From', required=True),
         'emp': fields.many2many('hr.employee', 'summary_emp_rel', 'sum_id', 'emp_id', 'Employee(s)'),
         'holiday_type': fields.selection([('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')], 'Select Holiday Type', required=True)
-        }
+    }
 
     _defaults = {
          'date_from': time.strftime('%Y-%m-%d'),
          'holiday_type': 'Validated',
-        }
+    }
 
     def print_report(self, cr, uid, ids, context=None):
         if context is None:
@@ -46,7 +46,7 @@ class hr_holidays_summary_employee(osv.osv_memory):
              'ids': [],
              'model': 'hr.employee',
              'form': data
-                 }
+            }
         return {
             'type': 'ir.actions.report.xml',
             'report_name': 'holidays.summary',