1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from openerp import tools
23 from openerp.osv import fields, osv
24 from .. import hr_recruitment
25 from openerp.addons.decimal_precision import decimal_precision as dp
28 class hr_recruitment_report(osv.Model):
29 _name = "hr.recruitment.report"
30 _description = "Recruitments Statistics"
32 _rec_name = 'date_create'
33 _order = 'date_create desc'
36 'user_id': fields.many2one('res.users', 'User', readonly=True),
37 'company_id': fields.many2one('res.company', 'Company', readonly=True),
38 'date_create': fields.datetime('Create Date', readonly=True),
39 'date_last_stage_update': fields.datetime('Last Stage Update', readonly=True),
40 'date_closed': fields.date('Closed', readonly=True),
41 'job_id': fields.many2one('hr.job', 'Applied Job',readonly=True),
42 'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'),
43 'type_id': fields.many2one('hr.recruitment.degree', 'Degree'),
44 'department_id': fields.many2one('hr.department','Department',readonly=True),
45 'priority': fields.selection(hr_recruitment.AVAILABLE_PRIORITIES, 'Appreciation'),
46 'salary_prop' : fields.float("Salary Proposed", digits_compute=dp.get_precision('Account')),
47 'salary_prop_avg' : fields.float("Avg. Proposed Salary", group_operator="avg", digits_compute=dp.get_precision('Account')),
48 'salary_exp' : fields.float("Salary Expected", digits_compute=dp.get_precision('Account')),
49 'salary_exp_avg' : fields.float("Avg. Expected Salary", group_operator="avg", digits_compute=dp.get_precision('Account')),
50 'partner_id': fields.many2one('res.partner', 'Partner',readonly=True),
51 'available': fields.float("Availability"),
52 'delay_close': fields.float('Avg. Delay to Close', digits=(16,2), readonly=True, group_operator="avg",
53 help="Number of Days to close the project issue"),
54 'last_stage_id': fields.many2one ('hr.recruitment.stage', 'Last Stage'),
58 tools.drop_view_if_exists(cr, 'hr_recruitment_report')
60 create or replace view hr_recruitment_report as (
63 s.create_date as date_create,
64 date(s.date_closed) as date_closed,
65 s.date_last_stage_update as date_last_stage_update,
71 sum(s.availability) as available,
76 sum(salary_proposed) as salary_prop,
77 (sum(salary_proposed)/count(*)) as salary_prop_avg,
78 sum(salary_expected) as salary_exp,
79 (sum(salary_expected)/count(*)) as salary_exp_avg,
80 extract('epoch' from (s.write_date-s.create_date))/(3600*24) as delay_close,
88 s.date_last_stage_update,
101 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: