问题
I would like to change something from mail.thread abstract class. So I inherited mail.thread and wrote override message_tracked function. But it did not call override function... just only called base function. Is it cause by mail.thread is Abstract Model?
I tried like that osv.osv and osv.AbstractModel and import this py file in init.py and put 'mail' module in depend dic of openerp.py
class mail_thread(osv.osv):
_inherit = 'mail.thread'
class mail_thread(osv.AbstractModel):
_inherit = 'mail.thread'
they did not call any function in this class def write or def message_track
If you do not mind, please explain me how to write override function for message_track.
回答1:
This is probably related to the issue described here: https://github.com/odoo/odoo/issues/9084
As a workaround you may try to solve this as described here: Override python function in odoo
I did it like this:
from openerp.addons.mail.mail_thread import mail_thread
message_new_orig = mail_thread.message_new
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
# call super function
msg_id = message_new_orig(self, cr, uid, msg_dict,
custom_values=custom_values, context=context)
# put custom code here
# ...
return msg_id
# install overide
mail_thread.message_new = message_new
来源:https://stackoverflow.com/questions/31936122/how-to-inherit-mail-thread-abstractmodel-and-override-function-from-this-class-i