问题描述
如何在使用 xml 选择其他字段时显示它?
场景:
fieldA 来自 account.voucher
并且有两个字段,分别是 field1 和 field2
fieldB 来自 account.voucher.line object
如果选择 field1,则显示 fieldB
如果选择了 field2,fieldB 将不可见
未捕获的错误:域中的未知字段 product_id.receipt_type [["fieldA","!=","field1"]]
<record id="view_purchase_receipt_form_lineid" model="ir.ui.view">
<field name="name">account.voucher.purchase.form.line.ids</field>
<field name="model">account.voucher</field>
<field name="inherit_id" ref="account_voucher.view_purchase_receipt_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']//field[@name='price_subtotal']" position="after">
<field name="fieldB" string="Field B" attrs="{'invisible':[('fieldA','!=','field1')]}"/>
</xpath>
</field>
</record>
class AccountVoucherLine(models.Model):
_inherit = "account.voucher.line"
fieldA = fields.Selection([
('field1','Field 1'),('field2','Field 2'),],'Field Type',required=True,index=True)
class AccountVoucher(models.Model):
_inherit = "account.voucher"
fieldB = fields.Char(string="Field B")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)