[IMP] hr_* Clean the code

bzr revid: psi@tinyerp.co.in-20100826045204-lxfawwkq2be62e8s
This commit is contained in:
psi (Open ERP) 2010-08-26 10:22:04 +05:30
parent c38d1e200a
commit da787061db
9 changed files with 32 additions and 32 deletions

View 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 \

View 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])):
@ -122,7 +122,7 @@ class hr_employee(osv.osv):
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'))))

View 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!'))