Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] hr_dms_field: Apply correct condition + apply .sudo() to prevent ACL error from dms.access.group #346

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions hr_dms_field/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ def write(self, vals):
"""
res = super().write(vals)
for item in self.filtered("dms_directory_ids"):
if "user_id":
if "user_id" in vals:
template = self.env["dms.field.template"]._get_template_from_model(
item._name
)
if template:
template._get_autogenerated_group(item)
template.sudo()._get_autogenerated_group(item)
return res

def unlink(self):
"""When deleting a record, we also delete the linked directories and the
auto-generated access group.
"""
for record in self.filtered("dms_directory_ids"):
group = self.env["dms.access.group"]._get_item_from_dms_field_ref(record)
group = (
self.env["dms.access.group"].sudo()._get_item_from_dms_field_ref(record)
)
record.sudo().dms_directory_ids.unlink()
group.sudo().unlink()
group.unlink()
return super().unlink()
Loading