19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:00 +01:00
parent a1137a1456
commit e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions

View file

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import survey_survey
from . import survey_user
from . import hr_resume_line

View file

@ -0,0 +1,30 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
class HrResumeLine(models.Model):
_inherit = 'hr.resume.line'
department_id = fields.Many2one(related="employee_id.department_id", store=True)
survey_id = fields.Many2one('survey.survey', string='Certification', readonly=True)
expiration_status = fields.Selection([
('expired', 'Expired'),
('expiring', 'Expiring'),
('valid', 'Valid')], compute='_compute_expiration_status', store=True)
@api.depends('date_end')
def _compute_expiration_status(self):
self.expiration_status = 'valid'
for line in self:
if line.date_end:
if line.date_end <= fields.Date.today():
line.expiration_status = 'expired'
elif line.date_end + relativedelta(months=-3) <= fields.Date.today():
line.expiration_status = 'expiring'
def copy_data(self, default=None):
vals_list = super().copy_data(default=default)
return [dict(vals, name=self.env._("%s (copy)", resume_line.name)) for resume_line, vals in zip(self, vals_list)]

View file

@ -0,0 +1,12 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class SurveySurvey(models.Model):
_inherit = 'survey.survey'
certification_validity_months = fields.Integer(
'Validity', required=False,
help='Specify the number of months the certification is valid after being awarded. '
'Enter 0 for certifications that never expire.')

View file

@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from dateutil.relativedelta import relativedelta
from odoo import fields, models
from odoo.fields import Domain
from odoo.tools import html2plaintext
class SurveyUserInput(models.Model):
class SurveyUser_Input(models.Model):
_inherit = 'survey.user_input'
def _mark_done(self):
@ -14,28 +16,40 @@ class SurveyUserInput(models.Model):
- The user is linked to an employee
- The user succeeded the test """
super(SurveyUserInput, self)._mark_done()
super()._mark_done()
certification_user_inputs = self.filtered(lambda user_input: user_input.survey_id.certification and user_input.scoring_success)
partner_has_completed = {user_input.partner_id.id: user_input.survey_id for user_input in certification_user_inputs}
employees = self.env['hr.employee'].sudo().search([('user_id.partner_id', 'in', certification_user_inputs.mapped('partner_id').ids)])
user_inputs_by_partner = certification_user_inputs.grouped('partner_id')
employees = self.env['hr.employee'].search(
[('user_id.partner_id', 'in', certification_user_inputs.partner_id.ids)])
resume_lines = self.env['hr.resume.line'].search(
Domain.OR(
Domain('employee_id', '=', employee.id)
& Domain('survey_id', 'in', user_inputs_by_partner[employee.user_id.partner_id].survey_id.ids)
for employee in employees
))
resume_survey_by_ids = resume_lines.grouped(
lambda resume_line: (resume_line.employee_id, resume_line.survey_id))
line_type = self.env.ref('hr_skills_survey.resume_type_certification', raise_if_not_found=False)
lines_to_create = []
today = fields.Date.today()
for employee in employees:
line_type = self.env.ref('hr_skills_survey.resume_type_certification', raise_if_not_found=False)
survey = partner_has_completed.get(employee.user_id.partner_id.id)
self.env['hr.resume.line'].create({
'employee_id': employee.id,
'name': survey.title,
'date_start': fields.Date.today(),
'date_end': fields.Date.today(),
'description': html2plaintext(survey.description) if survey.description else '',
'line_type_id': line_type and line_type.id,
'display_type': 'certification',
'survey_id': survey.id
})
class ResumeLine(models.Model):
_inherit = 'hr.resume.line'
display_type = fields.Selection(selection_add=[('certification', 'Certification')])
survey_id = fields.Many2one('survey.survey', string='Certification', readonly=True)
for user_input in user_inputs_by_partner[employee.user_id.partner_id]:
survey = user_input.survey_id
date_start = today
validity_month = survey.certification_validity_months
resume_line_vals = {
'employee_id': employee.id,
'name': survey.title,
'date_start': date_start,
'date_end': date_start + relativedelta(months=validity_month) if validity_month else False,
'description': html2plaintext(survey.description) if survey.description else '',
'line_type_id': line_type.id if line_type else False,
'survey_id': survey.id,
}
if existing_resume_survey := resume_survey_by_ids.get((employee, survey)):
existing_resume_survey.write(resume_line_vals)
else:
lines_to_create.append(resume_line_vals)
self.env['hr.resume.line'].create(lines_to_create)