[IMP]:hr_holidays:Improved SQL report.(Available Holidays).

bzr revid: apa@tinyerp.com-20100427104927-1683smsdb4g9xuvv
This commit is contained in:
apa-tiny 2010-04-27 16:19:27 +05:30
parent cfb21e7497
commit efc69230d3
2 changed files with 44 additions and 36 deletions

View File

@ -27,6 +27,7 @@ class available_holidays_report(osv.osv):
_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),
@ -35,6 +36,7 @@ class available_holidays_report(osv.osv):
'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),
}
def init(self, cr):
@ -46,8 +48,10 @@ class available_holidays_report(osv.osv):
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.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,
@ -68,7 +72,8 @@ class available_holidays_report(osv.osv):
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'),h.user_id,h.state
to_char(s.create_date, 'MM'),to_char(s.create_date, 'YYYY-MM-DD'),h.user_id,
h.state,h.department_id
)""")
available_holidays_report()

View File

@ -10,40 +10,32 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Available Holidays">
<field name="employee_id"/>
<field name="holiday_status_id"/>
<field name="max_leave"/>
<field name="taken_leaves"/>
<field name="employee_id" invisible="1"/>
<field name="holiday_status_id" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="max_leave" sum="Allocated Leaves"/>
<field name="taken_leaves" sum="Taken Leaves"/>
<field name="user_id" invisible="1"/>
<field name="remaining_leave"/>
<field name="remaining_leave" sum="Remaining Leaves"/>
<field name="year" invisible="1"/>
<field name="day" invisible="1"/>
<field name="month" invisible="1"/>
<field name="date" invisible="1"/>
</tree>
</field>
</record>
<record id="view_hr_available_holidays_report_form" model="ir.ui.view">
<field name="name">available.holidays.report.form</field>
<field name="model">available.holidays.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<tree string="Available Holidays">
<field name="employee_id" select="1"/>
<field name="holiday_status_id" select="1"/>
<field name="remaining_leave"/>
</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 orientation="horizontal" string="Available Holidays" type="bar">
<field name="holiday_status_id"/>
<field name="employee_id"/>
<field name="max_leave" operator="+"/>
<field name="taken_leaves" operator="+"/>
<field name="remaining_leave" operator="+"/>
<field group="True" name="employee_id"/>
<field group="True" name="holiday_status_id"/>
</graph>
</field>
</record>
@ -55,32 +47,42 @@
<field name="arch" type="xml">
<search string="Leaves">
<group>
<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"/>
<filter icon="terp-hr" string="This Year"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
help="Leaves in this year"/>
<filter icon="terp-hr" string="This Month"
name="month"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
help="Leaves in this month"/>
<filter icon="gtk-media-rewind"
string=" 7 Days "
separator="1"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
help="Leaves during last 7 days"/>
<separator orientation="vertical"/>
<field name="employee_id"/>
<field name="employee_id"/>
<field name="user_id" widget="selection">
<filter icon="terp-sale"
string="My Leaves"
default="1"
domain="[('user_id','=',uid)]"/>
<filter icon="terp-hr"
string="My Leaves"
domain="[('user_id','=',uid)]"/>
</field>
</group>
<newline/>
<group expand="0" string="Extended options..." 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 string="Employee" icon="terp-hr" context="{'group_by':'employee_id'}"/>
<filter string="User" name="User" icon="terp-hr" context="{'group_by':'user_id'}"/>
<separator orientation="vertical"/>
<filter string="User" icon="terp-hr" context="{'group_by':'user_id'}"/>
<filter string="Type" icon="terp-hr" context="{'group_by':'holiday_status_id'}"/>
<filter string="Department" icon="terp-hr" context="{'group_by':'department_id'}"/>
<separator orientation="vertical"/>
<filter string="Month" icon="terp-sale" context="{'group_by':'date'}"/>
<filter string="Year" icon="terp-sale" context="{'group_by':'year'}"/>
<filter string="Day" icon="terp-hr" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-hr" context="{'group_by':'date'}"/>
<filter string="Year" icon="terp-hr" context="{'group_by':'year'}"/>
</group>
</search>
</field>
@ -93,6 +95,7 @@
<field name="res_model">available.holidays.report</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_no_leaf':1,'group_by':[]}</field>
<field name="view_id" ref="view_hr_available_holidays_report_search"/>
</record>