Skip to content

Commit

Permalink
Update hr_job_category/models/hr.py
Browse files Browse the repository at this point in the history
Co-authored-by: Florent Xicluna <[email protected]>
  • Loading branch information
leemannd and florentx authored Oct 17, 2023
1 parent 9c52d1f commit a11ad49
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hr_job_category/models/hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ def write(self, vals):
return res

def unlink(self):
prev_data = self.read(["job_id"])
# Go through each record and delete tags associated with the previous
# job, then add the tags of the new job.
#
prev_data = {
res["id"]: res["job_id"][0]
for res in self.read(["job_id"]) if res["job_id"]
}
# Go through each record and delete tags associated with the previous job
for contract in self:
for data in prev_data:
self._remove_tags(contract.employee_id.id, data["job_id"][0])
return super(HRContract, self).unlink()
job_id = prev_data.get(contract.id)
if job_id:
contract._remove_tags(job_id)
return super().unlink()

0 comments on commit a11ad49

Please sign in to comment.