[FIX] hr_holidays: Fix the problem related to report Leaves by Department

bzr revid: psi@tinyerp.co.in-20100827053846-tlffr7s2zrze5rbq
This commit is contained in:
psi (Open ERP) 2010-08-27 11:08:46 +05:30
parent 5a65cd5923
commit 3690da3b9b
3 changed files with 14 additions and 18 deletions

View File

@ -94,13 +94,13 @@ class report_custom(report_rml):
emp_id={}
# done={}
cr.execute("select name from res_company")
cr.execute("SELECT name FROM res_company")
res=cr.fetchone()[0]
date_xml=[]
date_today=time.strftime('%Y-%m-%d %H:%M:%S')
date_xml +=['<res name="%s" today="%s" />' % (res,date_today)]
cr.execute("select id,name,color_name from hr_holidays_status order by id")
cr.execute("SELECT id, name, color_name FROM hr_holidays_status ORDER BY id")
legend=cr.fetchall()
today=datetime.datetime.today()
@ -221,23 +221,19 @@ class report_custom(report_rml):
elif data['model']=='ir.ui.menu':
for id in data['form']['depts']:
dept = obj_dept.browse(cr, uid, id, context=context)
cr.execute("""select dept.manager_id from hr_department dept\
where dept.id = %s""", (id,))
result=cr.fetchall()
if result==[]:
cr.execute("""SELECT id FROM hr_employee \
WHERE department_id = %s""", (id,))
emp_ids = [x[0] for x in cr.fetchall()]
if emp_ids==[]:
continue
dept_done=0
for d in range(0,len(result)):
emp_id[d] = obj_emp.search(cr, uid, [('user_id', '=', result[d][0])])
items = obj_emp.read(cr, uid, emp_id[d], ['id', 'name'])
for item in items:
if dept_done==0:
emp_xml += emp_create_xml(self, cr, uid, 1, holiday_type, row_id, dept.id, dept.name, som, eom)
row_id = row_id +1
dept_done=1
emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)
for item in obj_emp.read(cr, uid, emp_ids, ['id', 'name']):
if dept_done==0:
emp_xml += emp_create_xml(self, cr, uid, 1, holiday_type, row_id, dept.id, dept.name, som, eom)
row_id = row_id +1
dept_done=1
emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom)
row_id = row_id +1
# Computing the xml
xml='''<?xml version="1.0" encoding="UTF-8" ?>
<report>

View File

@ -34,7 +34,7 @@ class hr_holidays_summary_dept(osv.osv_memory):
}
_defaults = {
'date_from': time.strftime('%Y-%m-%d'),
'date_from': time.strftime('%Y-%m-01'),
'holiday_type': 'Validated'
}

View File

@ -33,7 +33,7 @@ class hr_holidays_summary_employee(osv.osv_memory):
}
_defaults = {
'date_from': time.strftime('%Y-%m-%d'),
'date_from': time.strftime('%Y-%m-01'),
'holiday_type': 'Validated',
}