How to write “write” function without effecting inherited class in Odoo 8?

a 夏天 提交于 2019-12-11 07:29:21

问题


The situation is as follows:

This is my .py file

class mom_meeting(osv.osv):

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

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')

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


回答1:


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

instead of this ->

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

you can give-> osv.osv.write(cr, uid, [rec.id], vals, context=None)

This will call directly write function of ORM...

Hope this helps....



来源:https://stackoverflow.com/questions/37760674/how-to-write-write-function-without-effecting-inherited-class-in-odoo-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!