树视图中的Odoo 10额外按钮触发创建功能

时间:2017-09-07 07:41:37

标签: python openerp

嘿伙计们,我在树形/窗体视图中的创建按钮旁边创建了一个按钮,但它没有触发我想要的功能,而是与创建相同。

templatess.xml     

<template id="template" xml:space="preserve">
    <!-- <t t-extend="FormView.buttons">
    <t t-jquery="button.oe_form_button_create" t-operation="after">
        <button type="button">My button</button>
     </t>
    </t> -->
    <t t-extend="ListView.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <t t-if="widget.model=='ba.data'">
                <button name="fetch" class="btn btn-primary btn-sm o_list_button_add" type="button">Fetch Data</button>
            </t>
        </t>
    </t>
</template>

ba_data.py

# -*- coding: utf-8 -*-

from odoo import models, fields, api, exceptions

class Session(models.Model):
    _name = 'ba.data'

    name = fields.Char(required=True)

    @api.one
    def fetch(self):
    # SOME CODE HERE

另外,如果可能的话,请告诉我如何添加导入而不是创建旁边的按钮。非常感谢你。

参考工作视图: Working view

0 个答案:

没有答案