Odoo打开新窗口

佩斯塔纳

我想在Odoo 11中的CRM机会中创建一个按钮。我想打开一个包含该机会的所有消息的窗口(模型mail.message)

我试图创建我的第一个插件。

这是我的结构:

  • / odoo /插件/测试
    • __init__.py
    • __manifest__.py
    • 楷模
      • __init__.py
      • test.py

这是我的代码:

/odoo/addons/test/__manifest__.py

{
'name': 'test',
'version': '2.0',
'category': 'Sales',
'sequence': 5,
'summary': 'test',
'description': "",
'website': 'https://test.net',
'depends': [
    'crm'
],
'data': [
],
'demo': [
],
'css': [],
'installable': True,
'application': True,
'auto_install': False,
}

/odoo/addons/test/__init__.py

from . import models

/odoo/addons/test/models/__init__.py

from . import test

/odoo/addons/test/models/test.py

from odoo import models, fields


class test_test(models.Model):
    _inherit = 'crm.lead'

    @api.multi
    def test_test(self):
        return {
            'name': 'test_test',
            'res_model': 'mail.message',
            'view_type': 'list',
            'view_mode': 'tree,list',
            'type': 'ir.actions.act_window',
            'target': 'inline'
        }

crm.lead.form。机会

 <button name='%(test_test)d' string="test" type="action" />

我安装了我的应用程序,但是该按钮不起作用,并且没有显示任何错误。而且我无法在UI中看到我的操作。

阿图尔·阿文德(Atul Arvind)

要从视图中调用函数,您需要定义对象类型按钮,如下所示。

<button name='test_test' string="test" type="object" />

它将test_test在模型中调用function crm.lead(确保您的按钮在crm.lead模型视图中。)

并且您需要像下面那样更改功能

@api.multi
def test_test(self):
    return {
        'name': 'test_test',
        'res_model': 'mail.message',
        'view_type': 'list',
        'view_mode': 'tree,list',
        'type': 'ir.actions.act_window',
        'target': 'new' # will open a popup with mail.message list
    }

希望这可以帮助!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章