[IMP] hr_holidays: Reports improved for holidays with category wise also

bzr revid: mra@tinyerp.com-20100518102525-gs25stucjcwkf7x4
This commit is contained in:
mra (Open ERP) 2010-05-18 15:55:25 +05:30
parent f065d01dfc
commit a938cbb9d4
4 changed files with 25 additions and 25 deletions

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
from osv import fields, osv
import tools
class available_holidays_report(osv.osv):
@ -31,6 +31,7 @@ class available_holidays_report(osv.osv):
('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),
'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),
@ -47,6 +48,7 @@ class available_holidays_report(osv.osv):
to_char(s.create_date, 'YYYY') as year,
to_char(s.create_date, 'MM') as month,
h.employee_id as employee_id,
h.category_id as category_id,
h.user_id as user_id,
h.state as state,
h.holiday_status_id as holiday_status_id,
@ -64,11 +66,10 @@ class available_holidays_report(osv.osv):
from hr_holidays h
left join hr_holidays_status s on (s.id = h.holiday_status_id)
where h.state='validate'
and h.employee_id is not null
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'),h.user_id,h.state, h.category_id
)""")
available_holidays_report()

View File

@ -11,6 +11,7 @@
<field name="arch" type="xml">
<tree string="Available Holidays">
<field name="employee_id"/>
<field name="category_id"/>
<field name="holiday_status_id"/>
<field name="max_leave"/>
<field name="taken_leaves"/>
@ -65,16 +66,12 @@
help="Leaves of this month"/>
<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>
<field name="user_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="Employee" icon="terp-hr" domain="[('category_id', '=', 'False')]" context="{'group_by':'employee_id'}"/>
<filter string="Category" icon="terp-hr" domain="[('employee_id', '=', 'False')]" context="{'group_by':'category_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'}"/>
@ -93,6 +90,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_user_id': uid}</field>
<field name="view_id" ref="view_hr_available_holidays_report_search"/>
</record>

View File

@ -18,13 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import tools
from osv import fields,osv
class hr_holidays_report(osv.osv):
_name = "hr.holidays.report"
_description = "Leaves Statistics"
_description = "Leaves Statistics By Employee and category"
_auto = False
_rec_name = 'date'
_columns = {
@ -36,7 +35,8 @@ class hr_holidays_report(osv.osv):
'date_from' : fields.datetime('Start Date', readonly=True),
'date_to' : fields.datetime('End Date', readonly=True),
'number_of_days_temp': fields.float('Number of Days', readonly=True),
'employee_id' : fields.many2one('hr.employee', "Employee's Name",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),
'user_id':fields.many2one('res.users', 'User', readonly=True),
'state': fields.selection([('draft', 'Draft'),
('confirm', 'Waiting Validation'),
@ -57,19 +57,20 @@ class hr_holidays_report(osv.osv):
date_trunc('day',s.date_to) as date_to,
s.number_of_days_temp,
s.employee_id,
s.category_id,
s.user_id as user_id,
to_char(s.create_date, 'YYYY') as year,
to_char(s.create_date, 'MM') as month,
s.state
from
hr_holidays s
where type='remove' and
s.employee_id is not null
where type='remove'
group by
s.create_date,s.state,s.date_from,s.date_to,
s.number_of_days_temp,s.employee_id,s.user_id
s.number_of_days_temp,s.employee_id,s.user_id,s.category_id
)
""")
hr_holidays_report()
class hr_holidays_remaining_leaves_user(osv.osv):
@ -106,3 +107,5 @@ class hr_holidays_remaining_leaves_user(osv.osv):
""")
hr_holidays_remaining_leaves_user()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -9,6 +9,7 @@
<tree string="Leaves Statistics">
<field name="date"/>
<field name="employee_id"/>
<field name="category_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="number_of_days_temp"/>
@ -61,16 +62,12 @@
<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>
<field name="user_id" widget="selection"/>
<field name="date"/>
<newline/>
<group expand="1" string="Group By..." colspan="10" col="12">
<filter string="Employee" name="employee" icon="terp-hr" context="{'group_by':'employee_id'}"/>
<filter string="Employee" name="employee" domain="[('category_id', '=', 'False')]" icon="terp-hr" context="{'group_by':'employee_id'}"/>
<filter string="Category" name="category" domain="[('employee_id', '=', 'False')]" icon="terp-hr" context="{'group_by':'category_id'}"/>
<separator orientation="vertical"/>
<filter string="State" icon="terp-hr" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
@ -82,11 +79,12 @@
</record>
<record id="action_hr_holidays_report_all" model="ir.actions.act_window">
<field name="name">Leaves By Employee</field>
<field name="name">Leaves</field>
<field name="res_model">hr.holidays.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="context">{'search_default_employee': 1}</field>
<field name="context">{'search_default_user_id': uid}</field>
<!-- <field name="context">{'search_default_employee': 1}</field>-->
<field name="search_view_id" ref="view_hr_holidays_report_search"/>
</record>