[IMP]:hr_holidays:Improved Available holidays report.
bzr revid: apa@tinyerp.com-20100318110050-lmkbwstxy99tx383
This commit is contained in:
@@ -25,11 +25,17 @@ class available_holidays_report(osv.osv):
|
||||
_name = "available.holidays.report"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'date': fields.datetime('Date', readonly=True),
|
||||
'year': fields.char('Year', size=4, 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', 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),
|
||||
'max_leave': fields.float('Allocated Leaves', readonly=True),
|
||||
'taken_leaves': fields.float('Taken Leaves', readonly=True),
|
||||
'remaining_leave': fields.float('Remaining Leaves',readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
||||
}
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'available_holidays_report')
|
||||
@@ -37,16 +43,33 @@ class available_holidays_report(osv.osv):
|
||||
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,
|
||||
h.employee_id as employee_id,
|
||||
h.user_id as user_id,
|
||||
h.state as state,
|
||||
h.holiday_status_id as holiday_status_id,
|
||||
sum(number_of_days) as remaining_leave
|
||||
from
|
||||
hr_holidays h
|
||||
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'
|
||||
where h.state='validate'
|
||||
and h.employee_id is not null
|
||||
and s.active <> 'f'
|
||||
group by h.holiday_status_id, h.employee_id
|
||||
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'),h.user_id,h.state
|
||||
|
||||
)""")
|
||||
available_holidays_report()
|
||||
|
||||
|
||||
@@ -12,7 +12,13 @@
|
||||
<tree string="Available Holidays">
|
||||
<field name="employee_id"/>
|
||||
<field name="holiday_status_id"/>
|
||||
<field name="max_leave"/>
|
||||
<field name="taken_leaves"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="remaining_leave"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="date" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -42,6 +48,48 @@
|
||||
</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">
|
||||
<filter icon="terp-hr"
|
||||
string="This Year"
|
||||
domain="[('year','=',time.strftime('%%Y'))]"
|
||||
help="Leaves of the year"/>
|
||||
<filter icon="terp-hr"
|
||||
string="This Month"
|
||||
domain="[('month','=',time.strftime('%%m'))]"
|
||||
help="Leaves of this month"/>
|
||||
<!--separator orientation="vertical"/>
|
||||
<filter icon="terp-hr"
|
||||
string="Today's Start Leave"
|
||||
domain="[('date_from','=',time.strftime('%%Y/%%m/%%d'))]"/>
|
||||
<filter icon="terp-hr"
|
||||
string="Today's End Leave"
|
||||
domain="[('date_to','=',time.strftime('%%Y/%%m/%%d'))]"/>
|
||||
<separator orientation="vertical"/-->
|
||||
<field name="employee_id"/>
|
||||
<field name="user_id" widget="selection">
|
||||
<filter icon="terp-sale"
|
||||
string="My Leaves"
|
||||
default="1"
|
||||
domain="[('user_id','=',uid)]"/>
|
||||
</field>
|
||||
<newline/>
|
||||
<group expand="1" string="Group By..." colspan="10" col="12">
|
||||
<filter string="Employee" icon="terp-hr" context="{'group_by':'employee_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="User" icon="terp-hr" context="{'group_by':'user_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Month" icon="terp-sale" context="{'group_by':'date'}"/>
|
||||
<filter string="Year" icon="terp-sale" context="{'group_by':'year'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="action_hr_available_holidays_report" model="ir.actions.act_window">
|
||||
@@ -49,7 +97,7 @@
|
||||
<field name="res_model">available.holidays.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="view_id" ref="view_hr_available_holidays_report_tree"/>
|
||||
<field name="view_id" ref="view_hr_available_holidays_report_search"/>
|
||||
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user