Skip to content
Open
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
9 changes: 9 additions & 0 deletions impersonate_login/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class BaseModel(models.AbstractModel):

def _prepare_create_values(self, vals_list):
result_vals_list = super()._prepare_create_values(vals_list)
# Keep core attachment access semantics intact.
# For temporary/generated attachments (often without res_model/res_id),
# read access falls back to creator ownership. Rewriting create_uid to
# the original impersonator can make the active impersonated user lose
# access immediately in the same flow (e.g. compose email after report).
if self._name == "ir.attachment":
return result_vals_list
if (
request
and request.session.get("impersonate_from_uid")
Expand All @@ -23,6 +30,8 @@ def _prepare_create_values(self, vals_list):
def write(self, vals):
"""Overwrite the write_uid with the impersonating user"""
res = super().write(vals)
if self._name == "ir.attachment":
return res
if (
request
and request.session.get("impersonate_from_uid")
Expand Down