0

我在清单.py中编写了 button.xml 和 qweb,但它没有用。

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"
    ],
4

2 回答 2

0

派拉特·阿蒂查特

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');
        }
    },
});
于 2020-07-07T06:27:46.650 回答
0
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>
于 2020-12-31T08:53:22.347 回答