我想从mail.thread抽象类中更改一些内容。所以我继承了mail.thread并编写了覆盖消息跟踪函数。但它没有调用重写函数。。。只是调用了基函数。是不是因为mail.thread是抽象模型?
我试过像osv.osv和osv.AbstractModel一样,将这个py文件导入init.py,并将'mail'模块放入openerp.py的dependent dic中

class mail_thread(osv.osv):
    _inherit = 'mail.thread'

class mail_thread(osv.AbstractModel):
    _inherit = 'mail.thread'

他们没有调用这个类中的任何函数def write或def message\u track
如果您不介意,请告诉我如何为消息轨迹编写覆盖函数。

最佳答案

这可能与此处描述的问题有关:
https://github.com/odoo/odoo/issues/9084
作为一种解决方法,您可以尝试按如下所述解决此问题:
Override python function in odoo
我是这样做的:

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

10-07 19:34
查看更多