[ADD] hr_attendance: Print timesheet by week => osv memory
bzr revid: mra@tinyerp.com-20100413064024-1oncb1wygdqqnep0
This commit is contained in:
parent
8f64f3d3ed
commit
62ed5f7d46
|
@ -39,6 +39,7 @@
|
|||
'hr_attendance_report.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/hr_attendance_bymonth_view.xml',
|
||||
'wizard/hr_attendance_byweek_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_attendance_demo.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
import sign_in_out
|
||||
import print_attendance_error
|
||||
from print_byweek import wiz_byweek
|
||||
import hr_attendance_byweek
|
||||
import hr_attendance_bymonth
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -30,6 +30,10 @@ class hr_attendance_bymonth(osv.osv_memory):
|
|||
'Month', required=True),
|
||||
'year': fields.integer('Year', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'month': lambda * a: time.gmtime()[1],
|
||||
'year': lambda * a: time.gmtime()[0],
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
datas = {
|
||||
|
@ -43,10 +47,6 @@ class hr_attendance_bymonth(osv.osv_memory):
|
|||
'datas': datas,
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'month': lambda * a: time.gmtime()[1],
|
||||
'year': lambda * a: time.gmtime()[0],
|
||||
}
|
||||
hr_attendance_bymonth()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -31,7 +31,7 @@
|
|||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="event_registration_values">
|
||||
<record model="ir.values" id="hr_attendance_month_values">
|
||||
<field name="model_id" ref="hr.model_hr_employee" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Print Timesheet by month</field>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,39 +15,36 @@
|
|||
# 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 <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import time
|
||||
|
||||
_date_form = '''<?xml version="1.0"?>
|
||||
<form string="Timesheets by week">
|
||||
<separator string="Select a starting and a end date" colspan="4"/>
|
||||
<field name="init_date"/>
|
||||
<newline/>
|
||||
<field name="end_date"/>
|
||||
</form>'''
|
||||
from osv import osv, fields
|
||||
|
||||
_date_fields = {
|
||||
'init_date': {'string':'Starting Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True},
|
||||
'end_date': {'string':'Ending Date', 'type':'date', 'default':lambda *a: time.strftime('%Y-%m-%d'), 'required':True}
|
||||
}
|
||||
class hr_attendance_byweek(osv.osv_memory):
|
||||
_name = 'hr.attendance.week'
|
||||
_description = 'Print Week Attendance Report'
|
||||
_columns = {
|
||||
'init_date': fields.date('Starting Date', required=True),
|
||||
'end_date': fields.date('Ending Date', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'init_date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
'end_date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
|
||||
class wiz_byweek(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':_date_form, 'fields':_date_fields, 'state':[('end','Cancel', 'gtk-cancel'), ('print','Print', 'gtk-ok')]}
|
||||
},
|
||||
'print': {
|
||||
'actions': [],
|
||||
'result': {'type': 'print', 'report': 'hr.attendance.allweeks', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wiz_byweek('hr.attendance.print_week')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
datas = {
|
||||
'ids': [],
|
||||
'model': 'hr.employee',
|
||||
'form': self.read(cr, uid, ids)[0]
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'hr.attendance.allweeks',
|
||||
'datas': datas,
|
||||
}
|
||||
hr_attendance_byweek()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_hr_attendance_week" model="ir.ui.view">
|
||||
<field name="name">Attendance Report Week</field>
|
||||
<field name="model">hr.attendance.week</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Print Attendance Report Weekly">
|
||||
<group col="4" colspan="6">
|
||||
<separator string="Select a starting and a end date" colspan="4"/>
|
||||
<field name="init_date"/>
|
||||
<field name="end_date"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button special="cancel" string="Cancel" icon='gtk-cancel'/>
|
||||
<button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_attendance_week" model="ir.actions.act_window">
|
||||
<field name="name">Print Timesheet by week</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.attendance.week</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="hr_attendance_week_values">
|
||||
<field name="model_id" ref="hr.model_hr_employee" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Print Timesheet by week</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_attendance_week'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">hr.employee</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue