Openerp 从其他类odoo 9调用函数

Openerp 从其他类odoo 9调用函数,openerp,odoo-9,Openerp,Odoo 9,在自定义模块中,我有两个类。如何在@api.one中通过单击按钮调用test2\u func进行类测试 我应该在def call_test2_funcself中添加什么 例如: class test(models.Model): _name = "test.class" _description = "TEST" @api.one def call_test2_func(self): """call test2_func here""" class test2(mo

在自定义模块中,我有两个类。如何在@api.one中通过单击按钮调用test2\u func进行类测试

我应该在def call_test2_funcself中添加什么

例如:

class test(models.Model):
    _name = "test.class"
    _description = "TEST"
@api.one
    def call_test2_func(self):
  """call test2_func here"""

class test2(models.Model):
    _name = "test2.class"
    _description = "TEST 2"

@api.one
    def test2_func(self):
        print("TEST 2")

也许我应该留下回复而不是评论。如果您使用的是Odoo和新的OpenERP api,则可以通过模型类中的self.env访问模型字典。因此,要在模型test2.class中调用函数test2_func,您应该编写

@api.one
def call_test2_func(self):
    self.env["test2.class"].test2_func()

要从另一个模型调用函数,可以使用self.env[model\u name].myfunction