情况如下:
这是我的.py文件
class mom_meeting(osv.osv):
_name = "mom.meeting"
_rec_name = 'meet_ref'
_inherit = ['mail.thread']
我在我的自定义模块中添加了邮件关注者或openchatter,现在当我尝试写一个"写"功能如下:
def write(self, cr, uid, ids, vals, context=None):
user_ids = []
sobj = self.pool.get('mom.meeting').browse(cr, uid, ids, context=None)
if rec.ch_prsn.user_id.id == uid or rec.min_prp.id == uid:
return super(mom_meeting, self).write(cr, uid, [rec.id], vals, context=None)
else:
raise osv.except_osv('Error', 'You dont have access right to edit this record, Please click Discard to revert changes')
它不允许任何其他用户在openchatter中发送消息。任何帮助/建议都会非常棒。谢谢!
答案 0 :(得分:0)
为了消除调用super方法的需要,你可以这样使用: -
而不是这个 - >
super(mom_meeting, self).write(cr, uid, [rec.id], vals, context=None)
你可以给 - > osv.osv.write(cr, uid, [rec.id], vals, context=None)
这将直接调用ORM的写函数...
希望这会有所帮助......