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