From da787061dba0a63effc95c8cf159bc8ea15e66e5 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Thu, 26 Aug 2010 10:22:04 +0530 Subject: [PATCH] [IMP] hr_* Clean the code bzr revid: psi@tinyerp.co.in-20100826045204-lxfawwkq2be62e8s --- addons/hr/hr_department.py | 2 +- addons/hr_attendance/hr_attendance.py | 18 +++++++++--------- .../wizard/hr_attendance_error.py | 2 +- addons/hr_contract/hr_contract.py | 12 ++++++------ addons/hr_evaluation/hr_evaluation.py | 4 ++-- addons/hr_expense/hr_expense.py | 6 +++--- addons/hr_holidays/hr_holidays.py | 8 ++++---- .../wizard/hr_holidays_summary_department.py | 6 +++--- .../wizard/hr_holidays_summary_employees.py | 6 +++--- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/addons/hr/hr_department.py b/addons/hr/hr_department.py index 825059bd46b..0f2c3a908ff 100644 --- a/addons/hr/hr_department.py +++ b/addons/hr/hr_department.py @@ -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 \ diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 842fe409d12..643e5d519c9 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -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')))) diff --git a/addons/hr_attendance/wizard/hr_attendance_error.py b/addons/hr_attendance/wizard/hr_attendance_error.py index 24109b11496..6c630b1e064 100644 --- a/addons/hr_attendance/wizard/hr_attendance_error.py +++ b/addons/hr_attendance/wizard/hr_attendance_error.py @@ -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!')) diff --git a/addons/hr_contract/hr_contract.py b/addons/hr_contract/hr_contract.py index 1d2962a0702..aa04761e9a7 100644 --- a/addons/hr_contract/hr_contract.py +++ b/addons/hr_contract/hr_contract.py @@ -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() diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 0b497c461e0..c80c12f10ff 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -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() diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index 681a06cd838..c5818536f8c 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -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): diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index efd5df4b480..b5f4534454f 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -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() diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_department.py b/addons/hr_holidays/wizard/hr_holidays_summary_department.py index a08354fd40d..06651e11d33 100644 --- a/addons/hr_holidays/wizard/hr_holidays_summary_department.py +++ b/addons/hr_holidays/wizard/hr_holidays_summary_department.py @@ -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', diff --git a/addons/hr_holidays/wizard/hr_holidays_summary_employees.py b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py index ca9ccc83db7..379ff7d76c7 100644 --- a/addons/hr_holidays/wizard/hr_holidays_summary_employees.py +++ b/addons/hr_holidays/wizard/hr_holidays_summary_employees.py @@ -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',