[FIX] Cleaning hr holidays reporting and dashbaords

bzr revid: fp@tinyerp.com-20101229165130-jfr2h23jo7mrjqzu
This commit is contained in:
Fabien Pinckaers 2010-12-29 17:51:30 +01:00
parent e5c69704a3
commit 65b33b9489
6 changed files with 29 additions and 248 deletions

View File

@ -10,52 +10,16 @@
parent="base.menu_hr_dasboard"
sequence="4"/>
<record model="ir.ui.view" id="view_holiday_allocation_leave_tree">
<field name="name">hr.holidays.allocation.leave.tree</field>
<field name="model">hr.holidays</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Leaves" >
<field name="name"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="holiday_status_id"/>
</tree>
</field>
</record>
<record id="action_view_holiday_status_board" model="ir.actions.act_window">
<field name="name">My Leaves</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','in',('confirm', 'validate')),('user_id','=',uid)]</field>
<field name="view_id" ref="view_holiday_allocation_leave_tree"/>
</record>
<record id="board_hr_holidays_form" model="ir.ui.view">
<field name="name">board.hr.holidays.form</field>
<field name="model">board.board</field>
<field name="inherit_id" ref="hr.board_hr_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/hpaned/child1" position="inside">
<action colspan="4" height="220" name="%(action_view_holiday_status_board)d" string="My Leaves"/>
</xpath>
</field>
</record>
<!-- Need to merge in above view -->
<record id="action_hr_holidays_leaves_by_month" model="ir.actions.act_window">
<field name="name">Leaves by Month</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">available.holidays.report</field>
<record model="ir.actions.act_window" id="action_hr_holidays_leaves_by_month">
<field name="name">My Leaves</field>
<field name="res_model">hr.holidays.status</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('user_id','=',uid)]</field>
<field name="context">{'group_by':['holiday_status_id'],'group_by_no_leaf':1}</field>
<field name="view_id" ref="hr_holidays.view_hr_available_holidays_report_graph"/>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="False"/>
<field name="context">{}</field>
<field name="domain">[]</field>
</record>
<record id="board_hr_holidays_leave_by_month_form" model="ir.ui.view">
<field name="name">board.hr.holidays.leave.month.form</field>
@ -64,7 +28,7 @@
<field name="inherit_id" ref="hr.board_hr_form"/>
<field name="arch" type="xml">
<xpath expr="/form/hpaned/child2" position="inside">
<action colspan="4" height="220" name="%(action_hr_holidays_leaves_by_month)d" string="Leaves By Month" />
<action colspan="4" height="220" name="%(action_hr_holidays_leaves_by_month)d" string="Leaves" />
</xpath>
</field>
</record>

View File

@ -3,53 +3,33 @@
<data>
<record id="action_view_holiday_status_manager_board" model="ir.actions.act_window">
<field name="name">All Employee Leaves</field>
<field name="name">Leaves To Validate</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','in',('confirm', 'validate'))]</field>
<field name="domain">[('state','in',('confirm', 'validate', 'validate1'))]</field>
<field name="view_id" ref="hr_holidays.view_holiday_allocation_tree"/>
</record>
<record id="action_hr_holidays_remaining_leaves_empoloyee_all" model="ir.actions.act_window">
<field name="name">Remaining Leaves by User</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.holidays.remaining.leaves.user</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="hr_holidays.view_hr_holidays_remaining_leaves_user_graph"/>
</record>
<record id="board_hr_holidays_manager_form" model="ir.ui.view">
<field name="name">board.hr.holidays.manager.form</field>
<field name="model">board.board</field>
<field name="inherit_id" ref="hr.board_hr_manager_form"/>
<field name="inherit_id" ref="hr.board_hr_manager_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="/form/hpaned/child1" position="inside">
<action colspan="4" height="220" name="%(action_view_holiday_status_manager_board)d" string="All Employee Leaves"/>
</xpath>
</field>
</record>
<record id="board_hr_holidays_manager_remaining_form" model="ir.ui.view">
<field name="name">board.hr.holidays.manager.remaining.form</field>
<field name="model">board.board</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr.board_hr_manager_form"/>
<field name="arch" type="xml">
<xpath expr="/form/hpaned/child2" position="inside">
<action colspan="4" height="220" name="%(action_hr_holidays_remaining_leaves_empoloyee_all)d" string="Remaining Leave by Type and User" />
</xpath>
<xpath expr="/form/hpaned/child1" position="inside">
<action colspan="4" height="220" name="%(action_view_holiday_status_manager_board)d" string="All Employee Leaves"/>
</xpath>
</field>
</record>
<menuitem
action="hr.open_board_hr_manager"
icon="terp-graph"
id="base.menu_hr_manager"
parent="base.menu_hr_dasboard"
groups = "base.group_hr_manager"
sequence="5"/>
sequence="5"/>
</data>
</openerp>

View File

@ -79,7 +79,7 @@ class hr_holidays_status(osv.osv):
'color_name': fields.selection([('red', 'Red'),('blue','Blue'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color in Report', required=True, help='This color will be used in the leaves summary located in Reporting\Leaves by Departement'),
'limit': fields.boolean('Allow to Override Limit', help='If you tick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'),
'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."),
'max_leaves': fields.function(_user_left_days, method=True, string='Maximum Leaves Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'),
'max_leaves': fields.function(_user_left_days, method=True, string='Maximum Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'),
'leaves_taken': fields.function(_user_left_days, method=True, string='Leaves Already Taken', help='This value is given by the sum of all holidays requests with a negative value.', multi='user_left_days'),
'remaining_leaves': fields.function(_user_left_days, method=True, string='Remaining Leaves', help='Maximum Leaves Allowed - Leaves Already Taken', multi='user_left_days'),
'double_validation': fields.boolean('Apply Double Validation', help="If its True then its Allocation/Request have to be validated by second validator")

View File

@ -19,71 +19,3 @@
#
##############################################################################
from osv import fields, osv
import tools
class available_holidays_report(osv.osv):
_name = "available.holidays.report"
_auto = False
_columns = {
'date': fields.date('Date', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'day': fields.char('Day', size=15, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'employee_id': fields.many2one ('hr.employee', "Employee's Name", readonly=True),
'category_id': fields.many2one('hr.employee.category', "Category's Name", readonly=True),
'holiday_status_id': fields.many2one('hr.holidays.status', 'Leave Type', readonly=True),
'max_leave': fields.float('Allocated Leaves', readonly=True),
'taken_leaves': fields.float('Taken Leaves', readonly=True),
'remaining_leave': fields.float('Remaining Leaves', readonly=True),
'department_id': fields.many2one('hr.department', 'Department', readonly=True),
'user_id': fields.many2one('res.users', 'User', readonly=True),
'state': fields.selection([('draft', 'Draft'),
('confirm', 'Waiting Validation'),
('refuse', 'Refused'),
('validate', 'Validated'),
('cancel', 'Cancelled')]
,'State', readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'available_holidays_report')
cr.execute("""
CREATE or REPLACE view available_holidays_report as (
SELECT
min(h.id) as id,
date_trunc('day',h.create_date) as date,
to_char(s.create_date, 'YYYY') as year,
to_char(s.create_date, 'MM') as month,
to_char(s.create_date, 'YYYY-MM-DD') as day,
h.employee_id as employee_id,
h.category_id as category_id,
h.user_id as user_id,
h.department_id,
h.state as state,
h.holiday_status_id as holiday_status_id,
sum(number_of_days) as remaining_leave,
(select sum(number_of_days_temp) from hr_holidays
where type='remove'
and employee_id=h.employee_id
and holiday_status_id=h.holiday_status_id
and state='validate') as taken_leaves,
(select sum(number_of_days_temp) from hr_holidays
where type='add'
and employee_id=h.employee_id
and holiday_status_id=h.holiday_status_id
and state='validate') as max_leave
FROM hr_holidays h
LEFT JOIN hr_holidays_status s on (s.id = h.holiday_status_id)
WHERE h.state='validate'
and s.active <> 'f'
GROUP BY h.holiday_status_id, h.employee_id,
date_trunc('day',h.create_date),to_char(s.create_date, 'YYYY'),
to_char(s.create_date, 'MM'), to_char(s.create_date, 'YYYY-MM-DD'), h.user_id,h.state, h.category_id, h.department_id
)""")
available_holidays_report()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -2,115 +2,22 @@
<openerp>
<data>
<!-- available holidays report -->
<record id="view_hr_available_holidays_report_tree" model="ir.ui.view">
<field name="name">available.holidays.report.tree</field>
<field name="model">available.holidays.report</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Available Holidays">
<field name="employee_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="category_id" invisible="1"/>
<field name="holiday_status_id" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="year" invisible="1"/>
<field name="date" invisible="1"/>
<field name="state" invisible="1"/>
<field name="max_leave" sum="Allocated Leaves"/>
<field name="taken_leaves" sum="Taken Leaves"/>
<field name="remaining_leave" sum="Remaining Leaves"/>
</tree>
</field>
</record>
<record id="view_hr_available_holidays_report_graph" model="ir.ui.view">
<field name="name">available.holidays.report.graph</field>
<field name="model">available.holidays.report</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Available Holidays" type="bar">
<field name="holiday_status_id"/>
<field name="taken_leaves" string="Taken Leaves" operator="+"/>
<field name="max_leave" string="Allocated Leaves" operator="+"/>
</graph>
</field>
</record>
<record id="view_hr_available_holidays_report_search" model="ir.ui.view">
<field name="name">available.holidays.report.search</field>
<field name="model">available.holidays.report</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Leaves">
<group>
<filter icon="terp-go-year" string=" Year " domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]" help="Available Leaves of current year"/>
<filter icon="terp-go-month" string=" Month " name="month"
domain="[('date','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
help="Available Leaves of current month"/>
<filter icon="terp-go-month" string=" Month-1 " separator="1"
domain="[('date','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('date','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
help="Available Leaves of last month"/>
<separator orientation="vertical"/>
<filter string="Validated" icon="terp-camera_test" domain="[('state','=','validate')]"/>
<separator orientation="vertical"/>
<field name="employee_id"/>
</group>
<newline/>
<group expand="0" string="Extended Filters..." colspan="10" col="12">
<field name="holiday_status_id" widget="selection"/>
<field name="department_id" widget="selection"/>
</group>
<newline/>
<group expand="1" string="Group By..." colspan="10" col="12">
<filter icon="terp-personal" string="Employee"
name="user" context="{'group_by':'employee_id'}"
help="Leaves by employee"/>
<filter string="Validation User" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/>
<separator orientation="vertical"/>
<filter string="Department" icon="terp-personal+" context="{'group_by':'department_id'}"/>
<separator orientation="vertical"/>
<filter icon="terp-stock_symbol-selection" string="Category" context="{'group_by':'category_id'}"
help="Leaves by category"/>
<filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'holiday_status_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
</group>
</search>
</field>
</record>
<record id="action_hr_available_holidays_report" model="ir.actions.act_window">
<field name="name">Leaves Analysis</field>
<field name="res_model">available.holidays.report</field>
<record model="ir.actions.act_window" id="action_hr_available_holidays_report">
<field name="res_model">hr.holidays</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="context">{'search_default_month':1,'search_default_user':1,'group_by':[], 'group_by_no_leaf':1}</field>
<field name="view_id" ref="view_hr_available_holidays_report_search"/>
<field name="view_mode">tree,form</field>
<field name="view_id" eval="view_holiday_simple"/>
<field name="context">{'search_default_group_employee': 1, 'search_default_group_type': 1}</field>
<field name="domain">[('holiday_type','=','employee')]</field>
<field name="search_view_id" ref="view_hr_holidays_filter"/>
</record>
<record model="ir.actions.act_window.view" id="action_hr_available_holidays_report_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="view_hr_available_holidays_report_tree"/>
<field name="act_window_id" ref="action_hr_available_holidays_report"/>
</record>
<menuitem
name="Leaves Analysis"
id="menu_hr_available_holidays_report_tree"
action="action_hr_available_holidays_report"
parent="menu_hr_reporting_holidays"/>
<record model="ir.actions.act_window.view" id="action_hr_available_holidays_report_graph">
<field name="sequence" eval="2"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="view_hr_available_holidays_report_graph"/>
<field name="act_window_id" ref="action_hr_available_holidays_report"/>
</record>
<menuitem name="Leaves Analysis" id="menu_hr_available_holidays_report_tree" action="action_hr_available_holidays_report" parent="menu_hr_reporting_holidays"/>
</data>
</openerp>

View File

@ -5,5 +5,3 @@
"access_hr_holydays_status_employee","hr.holidays.status employee","model_hr_holidays_status","base.group_user",1,0,0,0
"access_hr_holidays_remain_user","hr.holidays.ramain.user","model_hr_holidays_remaining_leaves_user","base.group_hr_user",1,1,1,1
"access_resource_calendar_leaves_manager","resource_calendar_leaves_manager","resource.model_resource_calendar_leaves","base.group_hr_manager",1,1,1,1
"access_available_holidays_report_user","hr.available.holidays.report.user","model_available_holidays_report","base.group_hr_user",1,1,1,1
"access_available_holidays_report_employee","hr.available.holidays.report.employee","model_available_holidays_report","base.group_user",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
5 access_hr_holydays_status_employee hr.holidays.status employee model_hr_holidays_status base.group_user 1 0 0 0
6 access_hr_holidays_remain_user hr.holidays.ramain.user model_hr_holidays_remaining_leaves_user base.group_hr_user 1 1 1 1
7 access_resource_calendar_leaves_manager resource_calendar_leaves_manager resource.model_resource_calendar_leaves base.group_hr_manager 1 1 1 1
access_available_holidays_report_user hr.available.holidays.report.user model_available_holidays_report base.group_hr_user 1 1 1 1
access_available_holidays_report_employee hr.available.holidays.report.employee model_available_holidays_report base.group_user 1 0 0 0