Python 我正在尝试实现不删除odoo中日历事件的功能。如何避免以下情况?
我继承了calendar.event并编写了以下自定义取消链接函数Python 我正在尝试实现不删除odoo中日历事件的功能。如何避免以下情况?,python,calendar,openerp,odoo-8,Python,Calendar,Openerp,Odoo 8,我继承了calendar.event并编写了以下自定义取消链接函数 class calendar_event(osv.osv): _inherit = "calendar.event" _rec_name = 'number' _columns = { 'number' : fields.char('Meeting ID',readonly=1), } '''_defaults = {
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
现在,该函数在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'
任何人都有办法解决这个问题,,而且它还链接到google_calendar.py的取消链接功能,使其更加复杂:(它还与google_calendar.py的取消链接功能相链接,使其更加复杂。)(