[ADD] hr_holidays: summary report dept wise => OSV memory
bzr revid: mra@tinyerp.com-20100415052414-ooweg59lx4p9lmp7
This commit is contained in:
parent
1588c6af13
commit
b8cf5efd2c
|
@ -55,6 +55,7 @@
|
|||
'hr_holidays_view.xml',
|
||||
'hr_holidays_wizard.xml',
|
||||
'hr_holidays_report.xml',
|
||||
'wizard/hr_holidays_summary_department_view.xml',
|
||||
#'process/hr_holidays_process.xml'
|
||||
],
|
||||
'demo_xml': [],
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
name="Holidays"
|
||||
parent="hr.menu_hr_reporting"
|
||||
sequence="3" />
|
||||
<wizard string="Holidays by Departement"
|
||||
<!--<wizard string="Holidays by Departement"
|
||||
name="hr.holidays.summary"
|
||||
id="holidays_summary"/>
|
||||
<menuitem name="Leaves by Departement" parent="menu_hr_reporting_holidays"
|
||||
id="holidays_summary"/>-->
|
||||
<!--<menuitem name="Leaves by Departement" parent="menu_hr_reporting_holidays"
|
||||
icon="STOCK_PRINT"
|
||||
action="holidays_summary"
|
||||
type="wizard"
|
||||
id="menu_holidays_summary" sequence="20"/>
|
||||
|
||||
-->
|
||||
<!-- restrict menu access to HR Manager -->
|
||||
<record model='ir.ui.menu' id="menu_holidays_summary">
|
||||
<field eval="[(6,0,[ref('hr.group_hr_manager')])]" name="groups_id"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -39,8 +39,8 @@ def strToDate(dt):
|
|||
dt_date=datetime.date(int(dt[0:4]),int(dt[5:7]),int(dt[8:10]))
|
||||
return dt_date
|
||||
else:
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
|
||||
def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
|
||||
display={}
|
||||
|
@ -48,11 +48,11 @@ def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
|
|||
count=0
|
||||
p_id=pooler.get_pool(cr.dbname).get('hr.holidays').search(cr,uid,[('employee_id','in',[empid,False]), ('type', '=', 'remove')])
|
||||
ids_date = pooler.get_pool(cr.dbname).get('hr.holidays').read(cr,uid,p_id,['date_from','date_to','holiday_status_id','state'])
|
||||
|
||||
|
||||
for index in range(1,61):
|
||||
diff=index-1
|
||||
current=som+datetime.timedelta(diff)
|
||||
|
||||
|
||||
for item in ids_date:
|
||||
if current >= strToDate(item['date_from']) and current <= strToDate(item['date_to']):
|
||||
if item['state'] in holiday_type:
|
||||
|
@ -216,13 +216,13 @@ class report_custom(report_rml):
|
|||
|
||||
emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,items['id'],items['name'],som, eom)
|
||||
row_id = row_id +1
|
||||
|
||||
|
||||
elif data['model']=='ir.ui.menu':
|
||||
for id in data['form']['depts'][0][2]:
|
||||
for id in data['form']['depts']:
|
||||
dept = pooler.get_pool(cr.dbname).get('hr.department').browse(cr, uid, id, context.copy())
|
||||
depts.append(dept)
|
||||
dept_ids = tuple(data['form']['depts'][0][2])
|
||||
|
||||
dept_ids = tuple(data['form']['depts'])
|
||||
|
||||
cr.execute("""select dept_user.user_id \
|
||||
from hr_department_user_rel dept_user \
|
||||
where dept_user.department_id = %s\
|
||||
|
@ -258,7 +258,7 @@ class report_custom(report_rml):
|
|||
%s
|
||||
</report>
|
||||
''' % (months_xml,date_xml, emp_xml)
|
||||
|
||||
|
||||
return xml
|
||||
|
||||
report_custom('report.holidays.summary', 'hr.holidays', '', 'addons/hr_holidays/report/holidays_summary.xsl')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,11 +15,11 @@
|
|||
# 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 holidays_summary
|
||||
import hr_holidays_summary_department
|
||||
import holidays_summary_employees
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import datetime
|
||||
import time
|
||||
import pooler
|
||||
|
||||
form='''<?xml version="1.0"?>
|
||||
<form string="Report Options">
|
||||
<field name="date_from" colspan="2" />
|
||||
<field name="holiday_type" colspan="2" />
|
||||
<field name="depts" colspan="4" />
|
||||
|
||||
</form>'''
|
||||
|
||||
zero_form='''<?xml version="1.0"?>
|
||||
<form string="Notification">
|
||||
<label string="You have to select at least 1 Department. Try again." colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
zero_fields={
|
||||
}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
def _check(self, cr, uid, data, context):
|
||||
data['form']['date_from']=time.strftime('%Y-%m-%d')
|
||||
data['form']['holiday_type']='Validated'
|
||||
|
||||
return data['form']
|
||||
|
||||
def _checkdepts(self, cr, uid, data, context):
|
||||
|
||||
if len(data['form']['depts'][0][2])==0:
|
||||
return 'notify'
|
||||
else:
|
||||
return 'report'
|
||||
|
||||
fields={
|
||||
'date_from':{
|
||||
'string':'From',
|
||||
'type':'date',
|
||||
'required':True,
|
||||
},
|
||||
'depts': {
|
||||
'string': 'Department(s)',
|
||||
'type': 'many2many',
|
||||
'relation': 'hr.department'
|
||||
},
|
||||
'holiday_type':{
|
||||
'string':"Select Holiday Type",
|
||||
'required':True,
|
||||
'type':'selection',
|
||||
'selection':[('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')]
|
||||
},
|
||||
}
|
||||
|
||||
states={
|
||||
'init':{
|
||||
'actions':[_check],
|
||||
'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel', 'gtk-cancel'), ('checkdept', 'Print', 'gtk-print')]}
|
||||
},
|
||||
'checkdept': {
|
||||
'actions': [],
|
||||
'result': {'type':'choice','next_state':_checkdepts}
|
||||
},
|
||||
'notify': {
|
||||
'actions': [],
|
||||
'result': {'type':'form','arch':zero_form,'fields':zero_fields,'state':[('end','Ok', 'gtk-ok')]}
|
||||
},
|
||||
'report':{
|
||||
'actions':[],
|
||||
'result':{'type':'print', 'report':'holidays.summary', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_report('hr.holidays.summary')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class hr_holidays_summary_dept(osv.osv_memory):
|
||||
_name = 'hr.holidays.summary.dept'
|
||||
_description = 'HR Holidays Summary Report By Department'
|
||||
_columns = {
|
||||
'date_from': fields.date('From', required=True),
|
||||
'depts': fields.many2many('hr.department', 'summary_dept_rel', 'sum_id', 'dept_id', 'Department(s)'),
|
||||
'holiday_type': fields.selection([('Validated','Validated'),('Confirmed','Confirmed'),('both','Both Validated and Confirmed')], 'Select Holiday Type', required=True)
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'date_from': time.strftime('%Y-%m-%d'),
|
||||
'holiday_type': 'Validated'
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
data = self.read(cr, uid, ids, [])[0]
|
||||
if not data['depts']:
|
||||
raise osv.except_osv(_('Error'), _('You have to select at least 1 Department. And try again'))
|
||||
datas = {
|
||||
'ids': [],
|
||||
'model': 'ir.ui.menu',
|
||||
'form': data
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'holidays.summary',
|
||||
'datas': datas,
|
||||
}
|
||||
|
||||
hr_holidays_summary_dept()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_hr_holidays_summary_dept" model="ir.ui.view">
|
||||
<field name="name">hr.holidays.summary.dept.form</field>
|
||||
<field name="model">hr.holidays.summary.dept</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Holidays by Departement">
|
||||
<group col="4" colspan="6">
|
||||
<field name="date_from"/>
|
||||
<field name="depts"/>
|
||||
<field name="holiday_type"/>
|
||||
</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-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hr_holidays_summary_dept" model="ir.actions.act_window">
|
||||
<field name="name">Holidays by Departement</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.holidays.summary.dept</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="Leaves by Departement"
|
||||
parent="menu_hr_reporting_holidays"
|
||||
action="action_hr_holidays_summary_dept"
|
||||
id="menu_account_central_journal"
|
||||
icon="STOCK_PRINT"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue