[ADD] hr_holidays: print summary by employee => osv memory
bzr revid: mra@tinyerp.com-20100415105220-vwoxot3apvg6kkw1
This commit is contained in:
parent
896e30c521
commit
b1cd4c9456
|
@ -56,6 +56,7 @@
|
||||||
'hr_holidays_wizard.xml',
|
'hr_holidays_wizard.xml',
|
||||||
'hr_holidays_report.xml',
|
'hr_holidays_report.xml',
|
||||||
'wizard/hr_holidays_summary_department_view.xml',
|
'wizard/hr_holidays_summary_department_view.xml',
|
||||||
|
'wizard/hr_holidays_summary_employees_view.xml',
|
||||||
#'process/hr_holidays_process.xml'
|
#'process/hr_holidays_process.xml'
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
<field eval="[(6,0,[ref('hr.group_hr_manager')])]" name="groups_id"/>
|
<field eval="[(6,0,[ref('hr.group_hr_manager')])]" name="groups_id"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<wizard string="Employee's Holidays"
|
<!--<wizard string="Employee's Holidays"
|
||||||
model="hr.employee" name="hr.holidays.summary.employee"
|
model="hr.employee" name="hr.holidays.summary.employee"
|
||||||
keyword="client_print_multi" id="wizard_holidays_summary" />
|
keyword="client_print_multi" id="wizard_holidays_summary" />-->
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -210,8 +210,7 @@ class report_custom(report_rml):
|
||||||
row_id=1
|
row_id=1
|
||||||
|
|
||||||
if data['model']=='hr.employee':
|
if data['model']=='hr.employee':
|
||||||
|
for id in data['form']['emp']:
|
||||||
for id in data['form']['emp'][0][2]:
|
|
||||||
items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr,uid,id,['id','name'])
|
items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr,uid,id,['id','name'])
|
||||||
|
|
||||||
emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,items['id'],items['name'],som, eom)
|
emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,items['id'],items['name'],som, eom)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import hr_holidays_summary_department
|
import hr_holidays_summary_department
|
||||||
import holidays_summary_employees
|
import hr_holidays_summary_employees
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
||||||
#
|
|
||||||
# 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="Employee's Holidays">
|
|
||||||
<field name="date_from" colspan="2" />
|
|
||||||
<field name="holiday_type" colspan="2" />
|
|
||||||
<field name="emp" colspan="4" invisible="True"/>
|
|
||||||
</form>'''
|
|
||||||
|
|
||||||
zero_form='''<?xml version="1.0"?>
|
|
||||||
<form string="Notification">
|
|
||||||
<label string="You have to select at least 1 Employee. 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'
|
|
||||||
data['form']['emp'] = data['ids']
|
|
||||||
return data['form']
|
|
||||||
|
|
||||||
def _checkemps(self, cr, uid, data, context):
|
|
||||||
|
|
||||||
if len(data['form']['emp'][0][2])==0:
|
|
||||||
return 'notify'
|
|
||||||
else:
|
|
||||||
return 'report'
|
|
||||||
|
|
||||||
fields={
|
|
||||||
'date_from':{
|
|
||||||
'string':'From',
|
|
||||||
'type':'date',
|
|
||||||
'required':True,
|
|
||||||
},
|
|
||||||
'holiday_type':{'string':"Select Holiday Type",'type':'selection','selection':[('Validated','Validated'),('Confirmed','Confirmed'),('both','Both')]},
|
|
||||||
'emp': {'string': 'Employee(s)', 'type': 'many2many', 'relation': 'hr.employee'},
|
|
||||||
}
|
|
||||||
|
|
||||||
states={
|
|
||||||
'init':{
|
|
||||||
'actions':[_check],
|
|
||||||
'result':{'type':'form', 'arch':form, 'fields':fields, 'state':[('end', 'Cancel','gtk-cancel'), ('checkemp', 'Print', 'gtk-print')]}
|
|
||||||
},
|
|
||||||
'checkemp': {
|
|
||||||
'actions': [],
|
|
||||||
'result': {'type':'choice','next_state':_checkemps}
|
|
||||||
},
|
|
||||||
'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.employee')
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
|
#
|
||||||
|
# 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_employee(osv.osv_memory):
|
||||||
|
_name = 'hr.holidays.summary.employee'
|
||||||
|
_description = 'HR Holidays Summary Report By Employee'
|
||||||
|
_columns = {
|
||||||
|
'date_from': fields.date('From', required=True),
|
||||||
|
'emp': fields.many2many('hr.employee', 'summary_emp_rel', 'sum_id', 'emp_id', 'Employee(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]
|
||||||
|
data['emp'] = context['active_ids']
|
||||||
|
datas = {
|
||||||
|
'ids': [],
|
||||||
|
'model': 'hr.employee',
|
||||||
|
'form': data
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.report.xml',
|
||||||
|
'report_name': 'holidays.summary',
|
||||||
|
'datas': datas,
|
||||||
|
}
|
||||||
|
|
||||||
|
hr_holidays_summary_employee()
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="view_hr_holidays_summary_employee" model="ir.ui.view">
|
||||||
|
<field name="name">hr.holidays.summary.employee.form</field>
|
||||||
|
<field name="model">hr.holidays.summary.employee</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Employee's Holidays">
|
||||||
|
<group col="4" colspan="6">
|
||||||
|
<field name="date_from"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="holiday_type"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="emp" invisible="True"/>
|
||||||
|
</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_employee" model="ir.actions.act_window">
|
||||||
|
<field name="name">Employee's Holidays</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">hr.holidays.summary.employee</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_holidays_summary_employee_value">
|
||||||
|
<field name="model_id" ref="hr.model_hr_employee" />
|
||||||
|
<field name="object" eval="1" />
|
||||||
|
<field name="name">Employee's Holidays</field>
|
||||||
|
<field name="key2">client_print_multi</field>
|
||||||
|
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_holidays_summary_employee'))" />
|
||||||
|
<field name="key">action</field>
|
||||||
|
<field name="model">hr.employee</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue