Skip to content

Commit 7a698f7

Browse files
committed
Merge PR #755 into 16.0
Signed-off-by sbidoul
2 parents 7c20ae0 + 507ab67 commit 7a698f7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

base_export_async/models/delay_export.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def export(self, params):
109109
attachment.name,
110110
)
111111

112+
if any(user.has_group("base.group_portal") for user in users):
113+
attachment.generate_access_token()
114+
url += f"&access_token={attachment.access_token}"
115+
112116
time_to_live = (
113117
self.env["ir.config_parameter"].sudo().get_param("attachment.ttl", 7)
114118
)

base_export_async/tests/test_base_export_async.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,22 @@ def test_cron_delete(self):
9898

9999
# The attachment must be deleted
100100
self.assertFalse(new_attachment.exists())
101+
102+
def test_portal_export(self):
103+
"""Check that we make attachments externally accessible for portal users"""
104+
portal_user = self.env["res.users"].create(
105+
{
106+
"login": "base_export_async_portal_user",
107+
"name": "base_export_async_portal_user",
108+
"groups_id": self.env.ref("base.group_portal").ids,
109+
}
110+
)
111+
params = json.loads(data_csv.get("data"))
112+
params["user_ids"] = portal_user.ids
113+
attachments = self.env["ir.attachment"].search([])
114+
mails = self.env["mail.mail"].search([])
115+
self.delay_export_obj.export(params)
116+
new_attachment = self.env["ir.attachment"].search([]) - attachments
117+
self.assertTrue(new_attachment.access_token)
118+
new_mail = self.env["mail.mail"].search([]) - mails
119+
self.assertIn("&access_token=", new_mail.body)

0 commit comments

Comments
 (0)