From bac6c2151f9f3138b18ec1e49adce593383181c6 Mon Sep 17 00:00:00 2001 From: "Ajay Chauhan (OpenERP)" Date: Tue, 16 Oct 2012 12:56:35 +0530 Subject: [PATCH] [IMP] hr_attendance: made report visible & added header in 'Attendance by Week' report bzr revid: cha@tinyerp.com-20121016072635-aqx7jmysakwkg7fz --- addons/hr_attendance/report/timesheet.py | 20 +++++++++++++++---- addons/hr_attendance/report/timesheet.xsl | 16 ++++++++++++++- .../wizard/hr_attendance_byweek.py | 1 + 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py index 900f982dc74..58c8efe6991 100644 --- a/addons/hr_attendance/report/timesheet.py +++ b/addons/hr_attendance/report/timesheet.py @@ -20,12 +20,15 @@ ############################################################################## +import time from datetime import datetime from dateutil.relativedelta import relativedelta import pooler from report.interface import report_rml from report.interface import toxml +from report import report_sxw +from tools.translate import _ import tools one_week = relativedelta(days=7) @@ -39,6 +42,7 @@ class report_custom(report_rml): def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') + emp_ids = datas['active_ids'] start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.date().weekday()) @@ -47,9 +51,16 @@ class report_custom(report_rml): if last_monday < first_monday: first_monday, last_monday = last_monday, first_monday + rpt_obj = pooler.get_pool(cr.dbname).get('hr.employee') + rml_obj=report_sxw.rml_parse(cr, uid, rpt_obj._name,context) + header_xml = ''' +
+ %s + %s +
+ ''' % (str(rml_obj.formatLang(time.strftime("%Y-%m-%d"),date=True))+' ' + str(time.strftime("%H:%M")),pooler.get_pool(cr.dbname).get('res.users').browse(cr,uid,uid).company_id.name) user_xml = [] - - for employee_id in ids: + for employee_id in emp_ids: emp = obj_emp.read(cr, uid, [employee_id], ['id', 'name'])[0] monday, n_monday = first_monday, first_monday + one_week stop, week_xml = False, [] @@ -103,12 +114,13 @@ class report_custom(report_rml): monday, n_monday = n_monday, n_monday + one_week user_xml.append(user_repr % '\n'.join(week_xml)) - xml = ''' %s + %s + %s - ''' % '\n'.join(user_xml) + ''' % (header_xml,_('Attendances By Week'),'\n'.join(user_xml)) xml = tools.ustr(xml).encode('utf8') return self.post_process_xml_data(cr, uid, xml, context) diff --git a/addons/hr_attendance/report/timesheet.xsl b/addons/hr_attendance/report/timesheet.xsl index f815c0880fc..bd3d596e34c 100644 --- a/addons/hr_attendance/report/timesheet.xsl +++ b/addons/hr_attendance/report/timesheet.xsl @@ -3,12 +3,15 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> + + + - + + @@ -36,9 +40,19 @@ + + + + + + + + + + Name: diff --git a/addons/hr_attendance/wizard/hr_attendance_byweek.py b/addons/hr_attendance/wizard/hr_attendance_byweek.py index 9ee69a937d1..454ba7764da 100644 --- a/addons/hr_attendance/wizard/hr_attendance_byweek.py +++ b/addons/hr_attendance/wizard/hr_attendance_byweek.py @@ -37,6 +37,7 @@ class hr_attendance_byweek(osv.osv_memory): def print_report(self, cr, uid, ids, context=None): datas = { 'ids': [], + 'active_ids': context['active_ids'], 'model': 'hr.employee', 'form': self.read(cr, uid, ids)[0] }