[FIX] Calendar : virtual ID fix. Close #4465
This commit is contained in:
parent
8347d36bf1
commit
f3c4688715
|
@ -32,7 +32,7 @@ def calendar_id2real_id(calendar_id=None, with_date=False):
|
|||
@param with_date: if a value is passed to this param it will return dates based on value of withdate + calendar_id
|
||||
@return: real event id
|
||||
"""
|
||||
if calendar_id and isinstance(calendar_id, (str, unicode)):
|
||||
if calendar_id and isinstance(calendar_id, (basestring)):
|
||||
res = calendar_id.split('-')
|
||||
if len(res) >= 2:
|
||||
real_id = res[0]
|
||||
|
@ -46,7 +46,7 @@ def calendar_id2real_id(calendar_id=None, with_date=False):
|
|||
|
||||
|
||||
def get_real_ids(ids):
|
||||
if isinstance(ids, (str, int, long)):
|
||||
if isinstance(ids, (basestring, int, long)):
|
||||
return calendar_id2real_id(ids)
|
||||
|
||||
if isinstance(ids, (list, tuple)):
|
||||
|
@ -625,14 +625,14 @@ class ir_model(osv.Model):
|
|||
_inherit = 'ir.model'
|
||||
|
||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
new_ids = isinstance(ids, (str, int, long)) and [ids] or ids
|
||||
new_ids = isinstance(ids, (basestring, int, long)) and [ids] or ids
|
||||
if context is None:
|
||||
context = {}
|
||||
data = super(ir_model, self).read(cr, uid, new_ids, fields=fields, context=context, load=load)
|
||||
if data:
|
||||
for val in data:
|
||||
val['id'] = calendar_id2real_id(val['id'])
|
||||
return isinstance(ids, (str, int, long)) and data[0] or data
|
||||
return isinstance(ids, (basestring, int, long)) and data[0] or data
|
||||
|
||||
|
||||
original_exp_report = openerp.service.report.exp_report
|
||||
|
@ -1138,7 +1138,7 @@ class calendar_event(osv.Model):
|
|||
if not context:
|
||||
context = {}
|
||||
|
||||
if isinstance(event_id, (str, int, long)):
|
||||
if isinstance(event_id, (basestring, int, long)):
|
||||
ids_to_browse = [event_id] # keep select for return
|
||||
else:
|
||||
ids_to_browse = event_id
|
||||
|
@ -1220,7 +1220,7 @@ class calendar_event(osv.Model):
|
|||
comparers = [((itemgetter(col[1:]), -1) if col[0] == '-' else (itemgetter(col), 1)) for col in sort_params]
|
||||
ids = [r['id'] for r in sorted(result_data, cmp=comparer)]
|
||||
|
||||
if isinstance(event_id, (str, int, long)):
|
||||
if isinstance(event_id, (basestring, int, long)):
|
||||
return ids and ids[0] or False
|
||||
else:
|
||||
return ids
|
||||
|
@ -1383,7 +1383,7 @@ class calendar_event(osv.Model):
|
|||
|
||||
@api.cr_uid_ids_context
|
||||
def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, **kwargs):
|
||||
if isinstance(thread_id, str):
|
||||
if isinstance(thread_id, basestring):
|
||||
thread_id = get_real_ids(thread_id)
|
||||
if context.get('default_date'):
|
||||
del context['default_date']
|
||||
|
@ -1509,7 +1509,7 @@ class calendar_event(osv.Model):
|
|||
for arg in args:
|
||||
if arg[0] == 'id':
|
||||
for n, calendar_id in enumerate(arg[2]):
|
||||
if isinstance(calendar_id, str):
|
||||
if isinstance(calendar_id, basestring):
|
||||
arg[2][n] = calendar_id.split('-')[0]
|
||||
return super(calendar_event, self)._name_search(cr, user, name=name, args=args, operator=operator, context=context, limit=limit, name_get_uid=name_get_uid)
|
||||
|
||||
|
@ -1528,7 +1528,7 @@ class calendar_event(osv.Model):
|
|||
self._set_date(cr, uid, values, id=ids[0], context=context)
|
||||
|
||||
for one_ids in ids:
|
||||
if isinstance(one_ids, (str, int, long)):
|
||||
if isinstance(one_ids, (basestring, int, long)):
|
||||
if len(str(one_ids).split('-')) == 1:
|
||||
ids = [int(one_ids)]
|
||||
else:
|
||||
|
@ -1624,7 +1624,7 @@ class calendar_event(osv.Model):
|
|||
for f in EXTRAFIELDS:
|
||||
if fields and (f not in fields):
|
||||
fields2.append(f)
|
||||
if isinstance(ids, (str, int, long)):
|
||||
if isinstance(ids, (basestring, int, long)):
|
||||
select = [ids]
|
||||
else:
|
||||
select = ids
|
||||
|
@ -1636,7 +1636,7 @@ class calendar_event(osv.Model):
|
|||
for calendar_id, real_id in select:
|
||||
res = real_data[real_id].copy()
|
||||
ls = calendar_id2real_id(calendar_id, with_date=res and res.get('duration', 0) > 0 and res.get('duration') or 1)
|
||||
if not isinstance(ls, (str, int, long)) and len(ls) >= 2:
|
||||
if not isinstance(ls, (basestring, int, long)) and len(ls) >= 2:
|
||||
res['start'] = ls[1]
|
||||
res['stop'] = ls[2]
|
||||
|
||||
|
@ -1672,7 +1672,7 @@ class calendar_event(osv.Model):
|
|||
for k in EXTRAFIELDS:
|
||||
if (k in r) and (fields and (k not in fields)):
|
||||
del r[k]
|
||||
if isinstance(ids, (str, int, long)):
|
||||
if isinstance(ids, (basestring, int, long)):
|
||||
return result and result[0] or False
|
||||
return result
|
||||
|
||||
|
@ -1711,7 +1711,7 @@ class mail_message(osv.Model):
|
|||
convert the search on real ids in the case it was asked on virtual ids, then call super()
|
||||
'''
|
||||
for index in range(len(args)):
|
||||
if args[index][0] == "res_id" and isinstance(args[index][2], str):
|
||||
if args[index][0] == "res_id" and isinstance(args[index][2], basestring):
|
||||
args[index][2] = get_real_ids(args[index][2])
|
||||
return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
|
||||
|
||||
|
@ -1733,7 +1733,7 @@ class ir_attachment(osv.Model):
|
|||
convert the search on real ids in the case it was asked on virtual ids, then call super()
|
||||
'''
|
||||
for index in range(len(args)):
|
||||
if args[index][0] == "res_id" and isinstance(args[index][2], str):
|
||||
if args[index][0] == "res_id" and isinstance(args[index][2], basestring):
|
||||
args[index][2] = get_real_ids(args[index][2])
|
||||
return super(ir_attachment, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)
|
||||
|
||||
|
@ -1741,7 +1741,7 @@ class ir_attachment(osv.Model):
|
|||
'''
|
||||
when posting an attachment (new or not), convert the virtual ids in real ids.
|
||||
'''
|
||||
if isinstance(vals.get('res_id'), str):
|
||||
if isinstance(vals.get('res_id'), basestring):
|
||||
vals['res_id'] = get_real_ids(vals.get('res_id'))
|
||||
return super(ir_attachment, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
|
|
Loading…
Reference in New Issue