From 4de051b07d60a594776dcc1ef9e9f33dc70f7711 Mon Sep 17 00:00:00 2001 From: Denis Leemann Date: Tue, 17 Oct 2023 12:29:36 +0200 Subject: [PATCH] Update hr_job_category/models/hr.py Co-authored-by: Florent Xicluna <142113+florentx@users.noreply.github.com> --- hr_job_category/models/hr.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hr_job_category/models/hr.py b/hr_job_category/models/hr.py index ebc1672a643..2fbee3ff58a 100644 --- a/hr_job_category/models/hr.py +++ b/hr_job_category/models/hr.py @@ -37,18 +37,18 @@ def _remove_tags(job_id): if tags_to_remove: employee.write({"category_ids": tags_to_remove}) - def _tag_employees(self, employee_id=None, job_id=None): - if not employee_id or not job_id: - return - employee = self.env["hr.employee"].browse(employee_id) - empl_tags = employee.category_ids + def _tag_employees(self, job_id): job = self.env["hr.job"].browse(job_id) - for tag in job.category_ids: - if tag not in empl_tags: - _logger.debug( - "Adding employee tag if job tag doesn't " "exists: %s", tag.name - ) - employee.write({"category_ids": [(4, tag.id)]}) + _logger.debug( + "Adding employee tags if job tags doesn't exist: %s", job.category_ids + ) + for employee in self.mapped("employee_id"): + tags_to_add = [ + (4, tag.id) + for tag in job.category_ids - employee.category_ids + ] + if tags_to_add: + employee.write(tags_to_add) @api.model def create(self, vals):