如果a字段不是False,我想應用odoo域。如何寫有條件的odoo域名?
['|',('versions_ids', '=', version_id),(False, '=', version_id)]
您喜歡我寫拋出這個錯誤
TypeError: unhashable type: 'list'
編輯:
對象擴展:
class sale_order_line(models.Model):
_inherit = 'sale.order.line'
version_id = fields.Many2one('product_cars_application.version',string='Version')
認爲延長
<record id="sale_cars_append" 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="." position="inside">
<script type='text/javascript' src='/product_cars_application/static/src/js/filter.js'></script>
</xpath>
<xpath expr="/form/sheet/notebook/page[1]/field[@name='order_line']/tree/field[@name='product_id']" position="before">
<!-- <button name="product_search" type="action" class="oe_highlight" icon="fa-car" /> -->
<field name="version_id"/>
</xpath>
<xpath expr="/form/sheet/notebook/page[1]/field[@name='order_line']/tree/field[@name='product_id']" position="attributes">
<attribute name = "domain">['|',('versions_ids', '=', version_id),(False, '=', version_id)]</attribute>
</xpath>
</field>
</record>
如果你不介意提供更多的上下文。在代碼中顯示你的域的定義(不僅僅是域)。顯示調用你的函數的字段定義。 –
@Phillip Stack編輯添加上下文 –
我看到過類似的東西。 version_ids是一個列表,version_id是一個int或False。列表int比較可能是一個問題。將'version_id'換成列表'('versions_ids','=',[version_id]) –