我继承了calendar.event并编写了以下自定义取消链接功能
class calendar_event(osv.osv):
_inherit = "calendar.event"
_rec_name = 'number'
_columns = {
'number' : fields.char('Meeting ID',readonly=1),
}
'''_defaults = {
'number' : lambda self,cr,uid,context={}:self.pool.get('ir.sequence').get(cr,uid,'calendar.event'),
}'''
def unlink(self, cr, uid, ids, context=None):
group_pool = self.pool.get('res.groups')
group_id = group_pool.search(cr, uid, [('name','=','Delete Calendar'),('users.id','=',uid)])
if group_id:
return super(osv.osv, self).unlink(cr, uid, ids, context=context)
else:
raise osv.except_osv('Error', 'You cannot delete this Calendar, Please contact Admin...')
return True
现在这个函数有超级unlink函数,如下面的calendar.event
def unlink(self, cr, uid, ids, can_be_deleted=True, context=None):
if not isinstance(ids, list):
ids = [ids]
res = False
ids_to_exclure = []
ids_to_unlink = []
for event_id in ids:
if can_be_deleted and len(str(event_id).split('-')) == 1: # if ID REAL
if self.browse(cr, uid, int(event_id), context).recurrent_id:
ids_to_exclure.append(event_id)
else:
ids_to_unlink.append(int(event_id))
else:
ids_to_exclure.append(event_id)
if ids_to_unlink:
res = super(calendar_event, self).unlink(cr, uid, ids_to_unlink, context=context)
if ids_to_exclure:
for id_to_exclure in ids_to_exclure:
res = self.write(cr, uid, id_to_exclure, {'active': False}, context=context)
return res
现在发生了什么事,我收到了以下错误:
unlink() got an unexpected keyword argument 'can_be_deleted'
任何人都有任何想法来克服这个问题,