问题
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