覆盖odoo中的python函数 [英] Override python function in odoo

查看:116
本文介绍了覆盖odoo中的python函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 odoo/server/openerp/models 中的 read_group 函数进行了一些更改.

I make some changes in the read_group function which is located in the odoo/server/openerp/models.

我现在需要的是在我自己的模块中重写此功能.因此,我将此功能复制到模块的 .py 文件中,但这对我不起作用.谁能告诉我该怎么做?

What I need now is to override this function in my own module. So I copy this function in the .py file of my module but this doesn't work for me. Can any one tell me how to do that?

推荐答案

请找到以下示例

from openerp import models
def read_group():
    #YOUR OVERRIDDEN Function

models.BaseModel.read_group = read_group

对于新API和旧API兼容性问题,您也可以使用_register_hook,如此链接上的示例所示. https://stackoverflow.com/a/34854721/1451220

For New API and old API compatibility issue you can also use _register_hook as given in example on this link. https://stackoverflow.com/a/34854721/1451220

这篇关于覆盖odoo中的python函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆