I created a custom controller with an action to download files that are automatically generated, the problem I am facing currently is how to link to this controller in the view without using a form tag (as the place of the link/button where I want it is already inside a form view), bellow is my controller:
class MyController(http.Controller):
_cp_path = '/sc'
@http.httprequest
def some_html(self, req, s_action=None, **kw):
return req.make_response(open('path_of_file').read(),
[('Content-Type', 'application/octet-stream; charset=binary'),
('Content-Disposition', content_disposition('1.docx', req))],
)
Bellow is the xml view and where I want to place the link to the url to download the given docx (please note it is not a static file it's auto-generated):
<record model="ir.ui.view" id="view_sefarer_applicant_form">
....
<field name="arch" type="xml">
<form string="Jobs - Recruitment Form" version="7.0">
.....
<sheet>
<div class="oe_right oe_button_box">
...
<button name="action_download_form" type="object" string="P014 Drug/Alcohol Delcaration" attrs="{'invisible':[('state','!=','done')]}"/>#this is where the link to the download url {sc/some_html} should be called
...
</sheet>
</form>
</field>
</record>
Any help or suggestions would be appreciated.