mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-26 03:52:08 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import re
|
||||
|
||||
from odoo import _
|
||||
|
||||
from odoo.addons.base.models.ir_qweb import QWebError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.http import request, route, Controller, content_disposition
|
||||
|
||||
|
||||
class HrEmployeeCV(Controller):
|
||||
|
||||
@route(["/print/cv"], type='http', auth='user')
|
||||
def print_employee_cv(self, employee_ids='', color_primary='#666666', color_secondary='#666666', **post):
|
||||
if not request.env.user._is_internal() or not employee_ids or re.search("[^0-9|,]", employee_ids):
|
||||
return request.not_found()
|
||||
|
||||
ids = [int(s) for s in employee_ids.split(',')]
|
||||
employees = request.env['hr.employee'].browse(ids)
|
||||
if not request.env.user.has_group('hr.group_hr_user') and employees.ids != request.env.user.employee_id.ids:
|
||||
return request.not_found()
|
||||
|
||||
resume_type_education = request.env.ref('hr_skills.resume_type_education', raise_if_not_found=False)
|
||||
skill_type_language = request.env.ref('hr_skills.hr_skill_type_lang', raise_if_not_found=False)
|
||||
|
||||
report = request.env.ref('hr_skills.action_report_employee_cv', False)
|
||||
|
||||
try:
|
||||
pdf_content, _dummy = request.env['ir.actions.report'].sudo()._render_qweb_pdf(
|
||||
report, employees.ids, data={
|
||||
'color_primary': color_primary,
|
||||
'color_secondary': color_secondary,
|
||||
'resume_type_education': resume_type_education,
|
||||
'skill_type_language': skill_type_language,
|
||||
'show_skills': 'show_skills' in post,
|
||||
'show_contact': 'show_contact' in post,
|
||||
'show_others': 'show_others' in post,
|
||||
})
|
||||
except QWebError as error:
|
||||
raise UserError(error)
|
||||
|
||||
if len(employees) == 1:
|
||||
report_name = _('Resume %s', employees.name)
|
||||
else:
|
||||
report_name = _('Resumes')
|
||||
|
||||
pdfhttpheaders = [
|
||||
('Content-Type', 'application/pdf'),
|
||||
('Content-Length', len(pdf_content)),
|
||||
('Content-Disposition', content_disposition(report_name + '.pdf'))
|
||||
]
|
||||
|
||||
return request.make_response(pdf_content, headers=pdfhttpheaders)
|
||||
Loading…
Add table
Add a link
Reference in a new issue