odoo18/addons_extensions/ftp_feed/controllers/controller.py

22 lines
688 B
Python

from odoo import http
from odoo.http import request
class FeedController(http.Controller):
@http.route('/feed/attachment/<int:attachment_id>', auth='user')
def get_feed_attachment(self, attachment_id, **kwargs):
attachment = request.env['ir.attachment'].sudo().search([
('id', '=', attachment_id),
'|',
('res_model', '=', 'ftp.feed'),
('res_model', '=', 'ftp.feed.comments')
])
if not attachment:
return request.not_found()
return http.send_file(
attachment._full_path(attachment.store_fname),
filename=attachment.name,
as_attachment=True
)