Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
120 Weergaven

Hello Everyone,

I want to use the Skill Management and E-Learning modules together. For example, when an employee finishes an assigned course, the related skill should be automatically updated under their Employee Skills section in the Resume tab.

I have added a form field under the course details called “Link Skill” and set the model as hr.skill. I also created an automation rule in Settings → Technical → Automation.

However, it’s still not updating correctly. I’ve tried everything, but it’s not importing the skills in the right way.

Your help would be greatly appreciated. Thank you!

Avatar
Annuleer
Beste antwoord

Hi,


Custom development is the cleanest way to make E-Learning and Skills Management talk to each other, because out of the box, they are completely separate apps.


Refer to the following code for updating the skills when an employee completes the course.

Try the code,


from odoo import models, fields, api


class SlideChannel(models.Model):

    _inherit = "slide.channel"


    # Skill to be linked with this course

    linked_skill_id = fields.Many2one("hr.skill", string="Linked Skill")



class SlideChannelPartner(models.Model):

    _inherit = "slide.channel.partner"


    @api.model

    def create(self, vals):

        rec = super().create(vals)

        rec._update_employee_skill_on_completion()

        return rec


    def write(self, vals):

        res = super().write(vals)

        if "completed" in vals and vals["completed"]:

            for rec in self:

                rec._update_employee_skill_on_completion()

        return res


    def _update_employee_skill_on_completion(self):

        """If course is completed and has linked skill, update employee's resume."""

        for rec in self:

            if rec.completed and rec.channel_id.linked_skill_id:

                # find employee for the user

                employee = self.env["hr.employee"].search(

                    [("user_id", "=", rec.partner_id.user_ids.id)], limit=1

                )

                if employee:

                    skill = rec.channel_id.linked_skill_id

                    # check if already has skill

                    emp_skill = self.env["hr.employee.skill"].search([

                        ("employee_id", "=", employee.id),

                        ("skill_id", "=", skill.id)

                    ], limit=1)


                    if not emp_skill:

                        # pick default level (lowest level in that skill type)

                        default_level = self.env["hr.skill.level"].search([], limit=1)

                        self.env["hr.employee.skill"].create({

                            "employee_id": employee.id,

                            "skill_id": skill.id,

                            "skill_level_id": default_level.id if default_level else False,

                        })


* Adds a “Linked Skill” field to each eLearning course.

* Hooks into slide.channel.partner (the record that tracks if a user completed a course).

* When a course is marked completed, the system:

          - Finds the corresponding employee for the user.

          - Gets the skill linked to the course.

          - Creates a new hr.employee.skill record if the employee doesn’t already have it.


Hope it helps

Avatar
Annuleer
Auteur Beste antwoord

Hello Cybrosys Techno Solutions Pvt.Ltd! Thanks for your feedback and let my try. 

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
feb. 25
1275
0
mrt. 25
1955
0
okt. 22
1140
2
jul. 25
644
2
dec. 23
2550