2016-11-15 10 views
1

フィールドがFalseでない場合は、odooドメインを適用したいと考えています。私はこのエラーをスロー書いたよう条件付きでodooドメインを書き込む方法は?

['|',('versions_ids', '=', version_id),(False, '=', version_id)] 

ドメインは

TypeError: unhashable type: 'list'

EDIT:

オブジェクトが拡張:

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> 
+1

より多くの文脈を提供していただければ幸いです。ドメインだけでなく、ドメインが定義されているコードを表示します。関数を呼び出すフィールド定義を表示します。 –

+0

@Phillip Stack編集コンテキストを追加する –

+0

私はこのようなものを見ました。 version_idsはリスト、version_idはintまたはFalseです。リストの比較はおそらく問題です。 '( 'versions_ids'、 '='、[version_id])リストで' version_id'をラップしてください。 –

答えて

0

以下を試してください。

<xpath expr="/form/sheet/notebook/page[1]/field[@name='order_line']/tree/field[@name='product_id']" position="attributes"> 
    <attribute name = "domain">['|',('version_ids', '=', version_id),('version_ids','=',False),'|',('version_id','=',False)]</attribute> 
</xpath> 
+0

ドメインの最初の部分が表示されます。 ( 'versions_ids'、 '='、version_id)。 しかし、私がversion_idがFalseの場合にのみこれを使用すると、versions_ids = Falseの製品しか表示されず、すべてを表示したい –

+0

私の提案を修正します。 –

+0

私はこれらのドメインが直感的ではないプロセスであることがよくあります。私はあなたが最初のタプルの前に 'OR'演算子を置くと、パーザは2番目のタプルが最初のタプルの最初の葉の代替値であると考えます。ですから、あなたの最初のタプルの後に '|'を置いておきたいでしょう。 –

0

これは、このようにする必要があり、

<xpath expr="/form/sheet/notebook/page[1]/field[@name='order_line']/tree/field[@name='product_id']" position="attributes"> 
    <attribute name = "domain">['|',('version_ids', '=', version_id),('version_ids','=',False)]</attribute> 
</xpath> 

ドメインのための別のオプション。

['|',('version_ids', '=', version_id),('version_ids','=',[(6,False,[])])] 
+0

sales.order.line.version_idの商品はsales.order.line.product_id.versions_idsにあり、sales.order.line.product_id.versions_ids = False ...表示する必要があります: 「version_id "not False show" sales.order.line.version_id "は" sales.order.line.product_id.versions_ids "にあります –

+0

バージョンIDがfalseの場合はどうなりますか? –

+0

version_idがfalseでない場合にのみ、ドメインを適用する必要があります。 で、Pythonになります。 ドメイン= [] あなたのコードVERSION_IDが定義されている場合は、show = Falseのversions_ids製品、と私は唯一のショーを行う必要があります。 version_idの場合:他の ドメインは= [(VERSION_ID 'version_ids'、 '='、)] which product_id.versions_ids = version_idの商品 –

関連する問題