Skip to content

Commit 32bb8fd

Browse files
committed
Merge PR #756 into 14.0
Signed-off-by sbidoul
2 parents 8b11584 + 25b5bfb commit 32bb8fd

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

base_export_async/models/delay_export.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def export(self, params):
106106
attachment.name,
107107
)
108108

109+
if any(user.has_group("base.group_portal") for user in users):
110+
attachment.generate_access_token()
111+
url += f"&access_token={attachment.access_token}"
112+
109113
time_to_live = (
110114
self.env["ir.config_parameter"].sudo().get_param("attachment.ttl", 7)
111115
)

base_export_async/tests/test_base_export_async.py

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

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

0 commit comments

Comments
 (0)