In older Odoo versions, for providing download links to temporary files we usually:
- added a TransientModel to our model class and added a BinaryField in there for the data:
class TheFileModel(models.TransientModel):
_name = "the_file_model"
data_file = fields.Binary("Some data")
- created in download button's action a new entry for this model, e.g.:
entry = self.env["the_file_model"].sudo().create({"data_file": base64.encodebytes(data)})- and finally got:
url = f"/web/content/the_file_model/{entry.id}/data_file/file_name.csv?download=true"
return {"type": "ir.actions.act_url", "url": url, "target": "new",}In Odoo 19, we constantly get 404 errors this way.
Is this due to the changed / shortened routing?
Or have we adapt this to the attachment ID (f"/web/content/{attachment.id}")?
Or some other mistake?
PS: Sorry, the text field threw away the last part. -.-