Odoo - 在 'Create' 旁边添加按钮

标签 odoo

[已解决]

<t t-extend="ListView.buttons">
    <t t-jquery="button.o_list_button_add" t-operation="after">
        <button type="button" class="btn btn-primary btn-sm">
            Create Customer Site
        </button>
    </t>
</t>

他们更改了 Odoo v10 中“o_list_button_add”中按钮类的名称。 在 web.base 中找到它

谢谢。

<小时/>

我想在“创建”按钮旁边添加一个按钮。

我尝试使用 xpath 标签,如下所示:

<template>
    <xpath expr="//div[@class='.o_list_buttons']" position="after">
        <button class="btn btn-primary" name="customer_button"
                string="Create Customer" type="action"/>
    </xpath>
</template>

但是没有成功。

有人知道怎么做吗?

[编辑]

我正在使用 Odoo v10。

这是 __manifest__.py

{
'name': "Broadband",

'summary': """
        Manage Network Sites
    """,

'description': """
""",

'author': "Author",
'website': "",

# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Draft',
'version': '0.1',

# any module necessary for this one to work correctly
'depends': ['base', 'product', 'base_multi_image', 'board', 'backend_theme_v10'],

# always loaded
'data': [
    'security/security.xml',
    'security/ir.model.access.csv',
    'views/views.xml',
    'views/product_view.xml',
    'views/wkf.xml',
    'views/component_view.xml',
    'views/competitor_view.xml',
    'views/voucher_view.xml',
    'views/partner_view.xml',
    'views/provider_view.xml',
    'views/site_board.xml',
    'views/customer.xml',
    'views/interventions.xml',
    'views/states_count.xml',
    'views/notification.xml',
],
# only loaded in demonstration mode
'demo': [
    'demo/demo.xml',
],
'qweb': ['views/templates.xml', 'views/views.xml'],
'installable': True,
'application': True,

}

我在 templates.xml 中使用您的代码。 也许我必须告诉 Odoo 在哪里使用它?

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">

<t t-extend="ListView.buttons" t-name="add_create_button">
    <t t-jquery="button.o_list_button_add" t-operation="after">
        <button type="button" class="btn btn-primary">
            Create Customer Site
        </button>
    </t>
</t>

</templates>

最佳答案

要在创建按钮后添加它,请使用:

对于ListView:

<template xml:space="preserve">
    <t t-extend="ListView.buttons">
        <t t-jquery="button.oe_list_add" t-operation="after">
            <!-- Your button here -->
        </t>
    </t>
</template>

对于FormView:

<t t-extend="FormView.buttons">
    <t t-jquery="button.oe_form_button_create" t-operation="after">
        <button type="button">My button</button>
     </t>
 </t>

__openerp__.py中添加对base模块的依赖:

{
    ...

    'depends': ['base'],

    ...
}

关于Odoo - 在 'Create' 旁边添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40938806/

相关文章:

javascript - 无法从网站发送电子邮件 - Odoo v9 社区

python - Odoo - 自定义模板菜单加载

Odoo 制造拣货 - 显示数量大于零的批处理 0

java - Odoo 请求中的 Many2Many 字段插入在 Android 中不起作用

odoo - OpenERP - 将另一个表中的相关字段带入 TreeView

openerp-7 - 如何在openerp中选择选项时隐藏/显示字段

odoo - 在弹出窗口中显示要删除的项目

odoo - 了解 OpenERP 域过滤器?

python - 如何在 odoo 上找到模态视图 ID?

python - 如何设置限制以允许最多选择 2 个字段?