2016-12-02 2 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» в v10 из Odoo. Найти его в 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> 

, но это не сработало.

Кто-нибудь знает, как это сделать?

[EDIT]

Я использую 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. Должен ли я сказать Оду, где его использовать, может быть?

<?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

Вы имеете в виду в манифесте? Да. –