How to write “write” function without effecting in

2019-07-25 12:26发布

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条回答
混吃等死
2楼-- · 2019-07-25 13:05

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....

查看更多
登录 后发表回答