[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
`<real>-<virtual>` and not `-<real>`
This commit is contained in:
Martin Trigaux
2016-05-20 11:16:29 +02:00
parent 7f9942c1a4
commit ae1c0e8b23
+2 -2
View File
@@ -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"))