簡體   English   中英

根據條件為Odoo10中的復選框添加顏色

[英]Add color to checkbox in Odoo10 according to condition

需要根據樹視圖裝飾器等條件為列表視圖中的復選框添加顏色。 如果樹視圖中的任何行不滿足特定條件,則需要更改 odoo 10 中復選框的顏色

將此代碼添加到您的模塊/static/src/xml/file.xml

<tr t-extend="ListView.row">
    <t t-jquery="td[class='o_list_record_selector']" t-operation="replace">
        <td t-if="options.selectable" class="o_list_record_selector">
            <t t-set="checked" t-value="options.select_view_id == record.get('id') ? 'checked' : null"/>
            <input t-if="options.radio" type="radio" name="radiogroup" t-att-checked="checked"/>
            <t t-if="view.model == 'account.asset.asset'">
                <t t-if="asData.state.value == 'make_draft'">
                    <div t-if="!options.radio" class="o_checkbox">
                        <input type="checkbox" name="radiogroup" style="outline-color: solid !important; outline-style: auto;" t-att-checked="checked"/><span/>
                    </div>
                </t>
                <t t-if="asData.state.value == 'draft'">
                    <div t-if="!options.radio" class="o_checkbox">
                        <input type="checkbox" name="radiogroup" style="outline-color: green !important; outline-style: auto;" t-att-checked="checked"/><span/>
                    </div>
                </t>

            </t>
            <t t-if="view.model != 'account.asset.asset'">

                <div t-if="!options.radio" class="o_checkbox">
                    <input type="checkbox" name="radiogroup" t-att-checked="checked"/><span/>
                </div>
            </t>
        </td>
    </t>
</tr>

我之前也問過類似的問題,自己找到了答案,看看這個,希望對你有幫助。

一般來說,想要改變view的行為,需要通過js來實現。 您必須在模板中調用 js 文件為

        <template id="assets_backend_general" inherit_id="web.assets_backend">
            <!-- load before document updated and can implement all page in the module-->
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/your_module/static/src/js/your_js_file.js"/>
            </xpath>
        </template>

然后將js代碼編寫為我給出的鏈接。

wiget 收音機上的 onchange 獲取值存在一個錯誤,當您單擊第二個收音機時,它不會立即觸發。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM