如何写“写"?功能而不会影响Odoo 8中的继承类? [英] How to write "write" function without effecting inherited class in Odoo 8?

查看:63
本文介绍了如何写“写"?功能而不会影响Odoo 8中的继承类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况如下:

这是我的.py文件

class mom_meeting(osv.osv):

    _name = "mom.meeting"
    _rec_name = 'meet_ref'
    _inherit = ['mail.thread']

并且我已经在我的自定义模块中添加了邮件关注者或openchatter,现在当我尝试编写如下写入"函数时:

and I had added the mail followers or openchatter in my custom module, now when I tried writing a "write" function as follows:

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中发送消息.任何帮助/建议都非常好.谢谢!

Its not allowing any other user to send a message in openchatter. Any help/suggestion would be really great. Thanks!

推荐答案

要消除调用超级方法的需要,可以这样使用:-

To eliminate need of calling super method, you can use like this:-

代替此->

super(mom_meeting, self).write(cr, uid, [rec.id], vals, context=None)

您可以给-> osv.osv.write(cr, uid, [rec.id], vals, context=None)

这将直接调用ORM的写函数...

This will call directly write function of ORM...

希望这会有所帮助....

Hope this helps....

这篇关于如何写“写"?功能而不会影响Odoo 8中的继承类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆