diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2016-12-01 11:24:33 +0100 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2016-12-01 11:52:27 +0100 |
| commit | 4f43ec4fcf924441ef1cdeebb14ee05970a2ee1b (patch) | |
| tree | 487229c56e680f42b74cea5ac6f95e73099ee276 /addons | |
| parent | e6ba7724066a4b6fafb8527dea3dcb86405fdc1b (diff) | |
[FIX] calendar: invitation template lang
- Create a calendar event
- Add invitees
The invitees receive a mail so they can accept/decline. When clicking,
the page is always displayed in the language of the administrator.
Since the `request` object is not directly associated to the attendee,
the template is not rendered in his language. Since (i) the template
should not be rendered lazily (see comment in code) and (ii)
`request.render()` does not allow the rendering in an arbitraty
language, we do a manual call to `render_template`.
opw-694718
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/calendar/controllers/main.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/addons/calendar/controllers/main.py b/addons/calendar/controllers/main.py index 78ff5f51351..4dd40e49201 100644 --- a/addons/calendar/controllers/main.py +++ b/addons/calendar/controllers/main.py @@ -41,22 +41,23 @@ class CalendarController(http.Controller): env = Environment(cr, SUPERUSER_ID, {}) attendee = env['calendar.attendee'].search([('access_token', '=', token)]) timezone = attendee.partner_id.tz - event = env['calendar.event'].with_context(tz=timezone).browse(int(id)) + lang = attendee.partner_id.lang or 'en_US' + event = env['calendar.event'].with_context(tz=timezone, lang=lang).browse(int(id)) # If user is logged, redirect to form view of event # otherwise, display the simplifyed web page with event informations if request.session.uid: return werkzeug.utils.redirect('/web?db=%s#id=%s&view_type=form&model=calendar.event' % (db, id)) - # NOTE : calling render return a lazy response. The rendering result will be done when the - # cursor will be closed. So it is requried to call `flatten` to make the redering before - # existing the `with` clause - response = request.render('calendar.invitation_page_anonymous', { - 'event': event, - 'attendee': attendee, - }) - response.flatten() - return response + # NOTE : we don't use request.render() since: + # - we need a template rendering which is not lazy, to render before cursor closing + # - we need to display the template in the language of the user (not possible with + # request.render()) + return env['ir.ui.view'].with_context(lang=lang).render_template( + 'calendar.invitation_page_anonymous', { + 'event': event, + 'attendee': attendee, + }) # Function used, in RPC to check every 5 minutes, if notification to do for an event or not @http.route('/calendar/notify', type='json', auth="user") |
