File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments