Skip to content

Commit b1cd243

Browse files
committed
[FIX] hr_skills: fix certification report
1 parent 90d7810 commit b1cd243

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22

3+
from . import hr_employee_certification_report
34
from . import hr_employee_cv_report
45
from . import hr_employee_skill_history_report
56
from . import hr_employee_skill_report
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import fields, models, tools
4+
5+
6+
class HrEmployeeCertificationReport(models.BaseModel):
7+
_name = 'hr.employee.certification.report'
8+
_auto = False
9+
_inherit = ["hr.manager.department.report"]
10+
_description = 'Employee Certification Report'
11+
_order = 'employee_id, level_progress desc'
12+
13+
company_id = fields.Many2one('res.company', readonly=True)
14+
department_id = fields.Many2one('hr.department', readonly=True)
15+
16+
skill_id = fields.Many2one('hr.skill', readonly=True)
17+
skill_type_id = fields.Many2one('hr.skill.type', readonly=True)
18+
skill_level = fields.Char(readonly=True)
19+
level_progress = fields.Float(readonly=True, aggregator='avg')
20+
active = fields.Boolean(readonly=False)
21+
22+
def init(self):
23+
tools.drop_view_if_exists(self.env.cr, self._table)
24+
25+
self.env.cr.execute("""
26+
CREATE OR REPLACE VIEW %(table)s AS (
27+
SELECT
28+
row_number() OVER () AS id,
29+
e.id AS employee_id,
30+
e.company_id AS company_id,
31+
v.department_id AS department_id,
32+
s.skill_id AS skill_id,
33+
s.skill_type_id AS skill_type_id,
34+
sl.level_progress / 100.0 AS level_progress,
35+
sl.name AS skill_level,
36+
(s.valid_to IS NULL OR s.valid_to >= '%(date)s') AND s.valid_from <= '%(date)s' AS active
37+
FROM hr_employee e
38+
LEFT JOIN hr_version v ON e.current_version_id = v.id
39+
LEFT OUTER JOIN hr_employee_skill s ON e.id = s.employee_id
40+
LEFT OUTER JOIN hr_skill_level sl ON sl.id = s.skill_level_id
41+
LEFT OUTER JOIN hr_skill_type st ON st.id = sl.skill_type_id
42+
WHERE e.active AND st.active IS True AND st.is_certification IS TRUE
43+
)
44+
""" % {
45+
'table': self._table,
46+
'date': fields.Date.context_today(self)
47+
})

0 commit comments

Comments
 (0)