Как добавить кнопку после кнопки создания / импорта на Odoo 11

Я пишу button.xml и qweb в manifest.py, но это не сработало.

button.xml (статический /src/xml/button.xml)

<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t t-extend="ListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button name="xxx" type="button" t-if='widget.modelName == "billing.info.functions"'
                    class="btn btn-sm btn-default o_import_button o_import_import">Upload
            </button>
        </t>
    </t>
</templates>

манифест.py

'qweb': [
        "static/src/xml/button.xml"
    ],

3 ответа

Трудно сказать, в каком состоянии вы хотите, попробуйте что-нибудь вроде этого:

 t-if="context['active_model'] === 'your.model'"

Пайрат Атичарт

XML файл Code добавить button:

Добавить обычай classдля управления видимостью кнопки [oe_list_button_custom_class]

<t t-extend="ListView.buttons">
    <t t-jquery="button.o_list_button_add" t-operation="after">
        <button type="button" class="btn btn-sm btn-default oe_list_button_custom_class">Upload</button>
    </t>
</t>

JS Code для обработки видимости и других операций:

var ListController = require('web.ListController');
ListController.include({
    renderButtons: function($node) {
        var self = this;
        this._super.apply(this, arguments);
        var button = $(this.$buttons.find('.oe_list_button_custom_class'));
        button.css("display", "none");
        if (this.modelName == "billing.info.functions") {
            button.css("display", 'inline');
        }
    },
});
      Try to extend ImportView insted of ListView as like below:

<templates>
    <t t-extend="ImportView.import_button">
        <t t-jquery="button.o_button_import" t-operation="after" >
            <button type="button" class="btn btn-secondary o_import_import">
                <span><i class="fa fa-file-excel-o"></i></span>
                Load File
            </button>
        </t>
    </t>
</templates>
Другие вопросы по тегам