I need to generate download link to ir.attachment file. I have 2 models as storage.directory and storage.file, in storage.file i have field
attachment_ids = fields.Many2many(
comodel_name='ir.attachment',
relation='storage_ir_attachment_rel',
string="Версии фалов",
ondelete='cascade',
required=True,
)
this need to be able to save file versions. I want to render this structure on website
<t t-foreach="dir.files" t-as="file">
<t t-foreach="file.attachment_ids" t-as="ir_file">
<div>New row:
<a t-attf-href="/web/content/#{ir_file.id}?download=true" target="_blank">
<span t-esc="ir_file.name"/>
</a>
</div>
</t>
</t>
when test it on localhost it's perfect but when i push it in server get error
Error to render compiling AST
AccessError: ('The requested operation ("read" on "Project" (project.project)) was rejected because of the following rules:\n- Project: multi-company\n\nNote: this might be a multi-company issue.\n\n(Records: тест (id=15), User: user_name (id=22))', None)
Template: website_commissioning_works.inner_directory
Path: /t/div/t/div/div/div/t[1]/ul/t/li/t/div/span
Node: <span t-esc="ir_file.name"/>
Looks like i need access_token like this
<a t-attf-href="/web/content/#{attachment.id}?download=true&access_token=#{attachment.access_token}" target="_blank">
but i don't understand where and how to define it
Aucun commentaire:
Enregistrer un commentaire