Ics file generation should be possible even when only event is installed as it is a basic feature of events. Moreover we need to be able to generate such files in order to replace the old outlook api used in the event templates, api which is not supported anymore. We decided to use ics files because it is supported by most calendar schedulers hence working with outlook. Linked to task #1853063 closes odoo/odoo#28477
24 lines
887 B
Python
24 lines
887 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from werkzeug.exceptions import NotFound
|
|
|
|
from odoo.http import Controller, request, route, content_disposition
|
|
|
|
|
|
class EventController(Controller):
|
|
|
|
@route(['''/event/<model("event.event", "[('state', 'in', ('confirm', 'done'))]"):event>/ics'''], type='http', auth="public")
|
|
def event_ics_file(self, event):
|
|
if not event or not event.registration_ids:
|
|
return request.not_found()
|
|
files = event._get_ics_file()
|
|
if not event.id in files:
|
|
return NotFound()
|
|
content = files[event.id]
|
|
return request.make_response(content, [
|
|
('Content-Type', 'application/octet-stream'),
|
|
('Content-Length', len(content)),
|
|
('Content-Disposition', content_disposition('%s.ics' % event.name))
|
|
])
|