2010-03-15 12:03:51 +00:00
|
|
|
# -*- 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/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
2010-07-03 10:21:52 +00:00
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp import tools
|
|
|
|
from openerp.osv import fields,osv
|
2010-03-15 12:03:51 +00:00
|
|
|
|
2010-04-06 13:24:56 +00:00
|
|
|
class hr_holidays_remaining_leaves_user(osv.osv):
|
|
|
|
_name = "hr.holidays.remaining.leaves.user"
|
2010-04-06 06:06:22 +00:00
|
|
|
_description = "Total holidays by type"
|
|
|
|
_auto = False
|
|
|
|
_columns = {
|
2014-05-21 09:52:05 +00:00
|
|
|
'name': fields.char('Employee'),
|
2010-04-07 13:17:58 +00:00
|
|
|
'no_of_leaves': fields.integer('Remaining leaves'),
|
2010-06-16 11:51:39 +00:00
|
|
|
'user_id': fields.many2one('res.users', 'User'),
|
2014-05-21 09:52:05 +00:00
|
|
|
'leave_type': fields.char('Leave Type'),
|
2010-07-03 10:21:52 +00:00
|
|
|
}
|
2010-04-06 06:06:22 +00:00
|
|
|
|
|
|
|
def init(self, cr):
|
2010-04-06 13:24:56 +00:00
|
|
|
tools.drop_view_if_exists(cr, 'hr_holidays_remaining_leaves_user')
|
2010-04-06 06:06:22 +00:00
|
|
|
cr.execute("""
|
2010-07-03 10:21:52 +00:00
|
|
|
CREATE or REPLACE view hr_holidays_remaining_leaves_user as (
|
|
|
|
SELECT
|
2010-04-06 13:24:56 +00:00
|
|
|
min(hrs.id) as id,
|
|
|
|
rr.name as name,
|
|
|
|
sum(hrs.number_of_days) as no_of_leaves,
|
2010-04-14 21:07:54 +00:00
|
|
|
rr.user_id as user_id,
|
2010-04-07 13:17:58 +00:00
|
|
|
hhs.name as leave_type
|
2010-07-03 10:21:52 +00:00
|
|
|
FROM
|
2010-04-07 13:17:58 +00:00
|
|
|
hr_holidays as hrs, hr_employee as hre,
|
|
|
|
resource_resource as rr,hr_holidays_status as hhs
|
2010-07-03 10:21:52 +00:00
|
|
|
WHERE
|
2010-04-07 13:17:58 +00:00
|
|
|
hrs.employee_id = hre.id and
|
|
|
|
hre.resource_id = rr.id and
|
2010-05-05 12:18:58 +00:00
|
|
|
hhs.id = hrs.holiday_status_id
|
2010-07-03 10:21:52 +00:00
|
|
|
GROUP BY
|
2010-04-14 21:07:54 +00:00
|
|
|
rr.name,rr.user_id,hhs.name
|
2010-04-06 06:06:22 +00:00
|
|
|
)
|
|
|
|
""")
|
2010-04-14 21:07:54 +00:00
|
|
|
|
2010-05-18 10:25:25 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|