From ae1c0e8b233f0e8e92f3c39afb398a8e9ca26022 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 10 May 2016 17:10:41 +0200 Subject: [PATCH] [FIX] calendar: fetching images of negative ids The mimetime fetching in /web/image/... may fail if: - calendar is installed - `id` is a string (using ?id=42 in the URI) - `id` is a negative number (company partners on odoo.com) The `search` override of `ir.attachment` in calendar detects if a number is a virtual ID when it contains a '-' and is a string. While it is not optimal to allow both int and str format for paramter `id`, make the verification of virtual ID in calendar more strict to only match the format `-` and not `-` --- addons/calendar/calendar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 08464fe1b97..86fd59a7d72 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -35,8 +35,8 @@ def calendar_id2real_id(calendar_id=None, with_date=False): @return: real event id """ if calendar_id and isinstance(calendar_id, (basestring)): - res = calendar_id.split('-') - if len(res) >= 2: + res = filter(None, calendar_id.split('-')) + if len(res) == 2: real_id = res[0] if with_date: real_date = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT, time.strptime(res[1], "%Y%m%d%H%M%S"))