亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何隱藏按鈕“創建發票”但基于條件?(Odoo 11)

如何隱藏按鈕“創建發票”但基于條件?(Odoo 11)

翻閱古今 2022-01-05 13:16:28
我真的被阻止了,我想隱藏“創建發票”按鈕,但根據條件,我的條件是,如果訂單行有服務,則隱藏按鈕。我創建了一個字段和一個函數,但最后總是出現模型中不存在該字段的錯誤,這是我的代碼:錯誤 :屬性中使用的字段“hide_invoice”必須存在于視圖中但缺失我的領域和功能(Python):from odoo import api, fields, models,_class SaleOrder(models.Model):    _inherit = 'sale.order'    hide_invoice = fields.Boolean(compute="_hide_button_invoice", string="",)    @api.multi    @api.depends('tasks_count')    def _hide_button_invoice(self):        for order in self:            if order.tasks_count > 0:                order.hide_invoice = True            elif order.tasks_count == 0:                order.hide_invoice = False 我的 XML(我在表單上看到它有效):<odoo><record id="button_invoice_view_form" model="ir.ui.view">        <field name="name">sale.order.button.create.form</field>        <field name="model">sale.order</field>        <field name="inherit_id" ref="sale.view_order_form"/>        <field name="arch" type="xml">            <xpath expr="//field[@name='partner_id']" position="before">                <field name ="hide_invoice"/>            </xpath>        </field></record></odoo>然后我想隱藏按鈕:<record id="sale_order_view_form" model="ir.ui.view">    <field name="name">sale.order.form</field>    <field name="model">sale.order</field>    <field name="inherit_id" ref="sale.view_order_form"/>    <field name="arch" type="xml">        <xpath expr="//group[@name='sale_pay']/field[@name='invoice_status']" position="attributes">            <attribute name="invisible" eval="False"/>        </xpath>        </xpath>    </field></record>
查看完整描述

1 回答

?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

您必須在標題級別顯示字段來處理這些。


就像在聲明按鈕之前執行以下代碼一樣。


<field name='hide_invoice' invisible='1'/>

并將其刪除在 partner_id 字段之前。


編輯


您可以嘗試使用以下 xml 代碼:


<record id="sale_order_view_form" model="ir.ui.view">

    <field name="name">sale.order.form</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

        <xpath expr="//group[@name='sale_pay']/field[@name='invoice_status']" position="attributes">

            <attribute name="invisible" eval="False"/>

        </xpath>

        <xpath expr="//button[@name='action_quotation_send']" position="before">

            <button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"

                type="action" class="btn-primary"

                attrs="{'invisible': [('invoice_status', '!=', 'to invoice')]}"/>

            <field name="hide_invoice" invisible="1"/>

            <button name="%(sale.action_view_sale_advance_payment_inv)d" string="Create Invoice"

                type="action" context="{'default_advance_payment_method': 'percentage'}"

                attrs="{'invisible': ['|','|',('hide_invoice', '=', True),('invoice_status', '!=', 'no'), ('state', '!=', 'sale')]}"/>

        </xpath>

    </field>

</record>


查看完整回答
反對 回復 2022-01-05
  • 1 回答
  • 0 關注
  • 166 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號