From c2bdeba0c2d51db626a913d8c1375a78d9f27982 Mon Sep 17 00:00:00 2001 From: "mra (Open ERP)" Date: Tue, 20 Apr 2010 11:41:38 +0530 Subject: [PATCH] [ADD] hr_timesheet: Print Employee Timesheet and Users Timesheet => OSV Memory bzr revid: mra@tinyerp.com-20100420061138-bpn2ai9nebmdhqh5 --- addons/hr_timesheet/__openerp__.py | 3 +- addons/hr_timesheet/hr_timesheet_report.xml | 8 +-- addons/hr_timesheet/report/users_timesheet.py | 20 +++---- addons/hr_timesheet/wizard/__init__.py | 8 +-- ...heet.py => hr_timesheet_print_employee.py} | 48 +--------------- .../hr_timesheet_print_employee_view.xml | 36 ++++++++++++ .../wizard/hr_timesheet_print_users.py | 56 +++++++++++++++++++ .../wizard/hr_timesheet_print_users_view.xml | 41 ++++++++++++++ .../wizard/wizard_print_timesheet_users.py | 56 ------------------- 9 files changed, 155 insertions(+), 121 deletions(-) rename addons/hr_timesheet/wizard/{wizard_print_timesheet.py => hr_timesheet_print_employee.py} (60%) create mode 100644 addons/hr_timesheet/wizard/hr_timesheet_print_users.py create mode 100644 addons/hr_timesheet/wizard/hr_timesheet_print_users_view.xml delete mode 100644 addons/hr_timesheet/wizard/wizard_print_timesheet_users.py diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index 92ffae79668..a917ed2df4c 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -45,7 +45,8 @@ to set up a management by affair. 'hr_timesheet_report.xml', 'hr_timesheet_wizard.xml', 'process/hr_timesheet_process.xml', - 'wizard/hr_timesheet_print_employee_view.xml' + 'wizard/hr_timesheet_print_employee_view.xml', + 'wizard/hr_timesheet_print_users_view.xml' ], 'demo_xml': ['hr_timesheet_demo.xml'], 'installable': True, diff --git a/addons/hr_timesheet/hr_timesheet_report.xml b/addons/hr_timesheet/hr_timesheet_report.xml index 66ee5c4856c..6fa7185c7e9 100644 --- a/addons/hr_timesheet/hr_timesheet_report.xml +++ b/addons/hr_timesheet/hr_timesheet_report.xml @@ -22,23 +22,23 @@ groups="hr.group_hr_manager" />--> - + - - +--> diff --git a/addons/hr_timesheet/report/users_timesheet.py b/addons/hr_timesheet/report/users_timesheet.py index c179c3d3fff..9755d2d5871 100644 --- a/addons/hr_timesheet/report/users_timesheet.py +++ b/addons/hr_timesheet/report/users_timesheet.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -42,24 +42,24 @@ def emp_create_xml(cr, id, som, eom): "and line.user_id=%s and line.date >= %s and line.date < %s " "order by line.date", (id, som.strftime('%Y-%m-%d'), eom.strftime('%Y-%m-%d'))) - + # Sum by day month = {} for presence in cr.dictfetchall(): day = int(presence['date'][-2:]) month[day] = month.get(day, 0.0) + presence['amount'] - + xml = ''' %.2f ''' time_xml = ([xml % (day, amount) for day, amount in month.iteritems()]) - + # Computing the employee cr.execute("select name from res_users where id=%s", (id,)) emp = cr.fetchone()[0] - + # Computing the xml xml = ''' @@ -73,13 +73,13 @@ class report_custom(report_rml): def get_month_name(self, cr, uid, month): _months = {1:_("January"), 2:_("February"), 3:_("March"), 4:_("April"), 5:_("May"), 6:_("June"), 7:_("July"), 8:_("August"), 9:_("September"), 10:_("October"), 11:_("November"), 12:_("December")} return _months[month] - + def get_weekday_name(self, cr, uid, weekday): _weekdays = {1:_('Mon'), 2:_('Tue'), 3:_('Wed'), 4:_('Thu'), 5:_('Fri'), 6:_('Sat'), 7:_('Sun')} return _weekdays[weekday] def create_xml(self, cr, uid, ids, data, context): - + # Computing the dates (start of month: som, and end of month: eom) som = datetime.date(data['form']['year'], data['form']['month'], 1) eom = som + datetime.timedelta(lengthmonth(som.year, som.month)) @@ -87,9 +87,9 @@ class report_custom(report_rml): date_xml += ['' % (x, self.get_weekday_name(cr, uid, som.replace(day=x).weekday()+1), som.replace(day=x).weekday()+1) for x in range(1, lengthmonth(som.year, som.month)+1)] date_xml.append('') date_xml.append('2.5cm%s,2cm\n' % (',0.7cm' * lengthmonth(som.year, som.month))) - + emp_xml='' - for id in data['form']['user_ids'][0][2]: + for id in data['form']['user_ids']: emp_xml += emp_create_xml(cr, id, som, eom) # Computing the xml diff --git a/addons/hr_timesheet/wizard/__init__.py b/addons/hr_timesheet/wizard/__init__.py index 88b1cb40415..8619dcbcfea 100644 --- a/addons/hr_timesheet/wizard/__init__.py +++ b/addons/hr_timesheet/wizard/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,13 +15,13 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## import sign_in_out -import wizard_print_timesheet -import wizard_print_timesheet_users +import hr_timesheet_print_employee +import hr_timesheet_print_users # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet/wizard/wizard_print_timesheet.py b/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py similarity index 60% rename from addons/hr_timesheet/wizard/wizard_print_timesheet.py rename to addons/hr_timesheet/wizard/hr_timesheet_print_employee.py index 255d949025a..d2e9a54f836 100644 --- a/addons/hr_timesheet/wizard/wizard_print_timesheet.py +++ b/addons/hr_timesheet/wizard/hr_timesheet_print_employee.py @@ -18,41 +18,13 @@ # along with this program. If not, see . # ############################################################################## - import datetime -import wizard from osv import osv, fields -import netsvc - -dates_form = ''' -
- - - -''' - - -dates_form_ro = ''' -
- - - -''' - -dates_fields = { - 'month': dict(string=u'Month', type='selection', required=True, selection=[(x, datetime.date(2000, x, 1).strftime('%B')) for x in range(1, 13)]), - 'year': dict(string=u'Year', type=u'integer', required=True), - 'user_id' : dict(string=u'User', type='many2one', relation='res.users', required=True), -} - -def _get_value(self, cr, uid, data, context): - today = datetime.date.today() - return dict(month=today.month, year=today.year, user_id=uid) class analytical_timesheet_employee(osv.osv_memory): _name = 'hr.analytical.timesheet.employee' - _description = 'Print Employee Timesheet' + _description = 'Print Employee Timesheet & Print My Timesheet' _columns = { 'month': fields.selection([(x, datetime.date(2000, x, 1).strftime('%B')) for x in range(1, 13)], 'Month', required=True), @@ -82,20 +54,4 @@ class analytical_timesheet_employee(osv.osv_memory): 'datas': datas, } analytical_timesheet_employee() - -class wizard_report_my(wizard.interface): - states = { - 'init': { - 'actions': [_get_value], - 'result': {'type':'form', 'arch':dates_form_ro, 'fields':dates_fields, 'state':[ ('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]} - }, - 'report': { - 'actions': [], - 'result': {'type':'print', 'report':'hr.analytical.timesheet', 'state':'end'} - } - } -wizard_report_my('hr.analytical.timesheet.my') - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml b/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml index 63a073b3f31..a3b53a05d22 100644 --- a/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml +++ b/addons/hr_timesheet/wizard/hr_timesheet_print_employee_view.xml @@ -2,6 +2,7 @@ + hr.analytical.timesheet.employee.form hr.analytical.timesheet.employee @@ -35,5 +36,40 @@ parent="menu_hr_reporting_timesheet" groups="hr.group_hr_manager" /> + + + + hr.analytical.timesheet.my.form + hr.analytical.timesheet.employee + form + +
+ + + + + + +