2016-12-02 74 views
3

[解决]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> 

他们的按钮类的“o_list_button_add”在Odoo的V10更名。 找到它在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> 

回答

2

create按钮使用添加:

对于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> 

添加到扶养模块base__openerp__.py

{ 
    ... 

    'depends': ['base'], 

    ... 
} 
+0

感谢您的回答,但它不起作用。 我试图把它放在视图或模板文件中,但它不会添加任何东西。 –

+0

@MicheleZaccheddu你是否将它添加为qweb模板? – Zety

+0

你的意思是在清单中吗?是的,我做到了。 –

相关问题