![](/img/trans.png)
[英]Attrs validation checking when an attribute is another attrs object
[英]How to access a field of another model in a button with the attrs attribute?
我如何從sale.order.line
模型中訪問字段product_id.product_tmpl_id.type
。
我在xml視圖中有以下按鈕:
button name="print_report" string="Print" type="object" icon="gtk-print" attrs="{'invisible':[('product_id.product_tmpl_id.type', '!=', 'product')]}"/>.
通過此語句,Odoo向我顯示了以下錯誤:
Uncaught Error: Campo desconocido product_id.product_tmpl_id.type en el dominio [["product_id.product_tmpl_id.type","!=","product"]]
我感謝您的幫助。 謝謝
您確定在按鈕視圖中聲明了product_id字段嗎? 如果是這樣,並且還無法正常工作,那么您可以嘗試在sales.order.line中創建一個相關字段
type = fields.Selection(related='product_id.product_tmpl_id.type')
並將其用於領域
[('type', '!=', 'product')]
(記住在視圖內部放置類型字段,即使是不可見的)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.