openerp
  • odoo-8
  • 2016-07-01 2 views 0 likes 
    0

    私はこの2つのクラスを持っています。odoo - 別のクラスのフィールドに基づくドメインフィルタ

    この

    class Relocation(models.Model): 
    _name = 'test.plan_relocation' 
    
    type = fields.Selection() 
    price_id = fields.Many2one('test.plan_price',domain="[('type','=',type)]") 
    relocation_line_ids = fields.One2many('test.plan_relocation_line','relocation_id') 
    

    この

    class RelocationLine(models.Model): 
    _name = 'test.plan_relocation_line' 
    
    relocation_id = fields.Many2one('test.plan_relocation') 
    source_id = fields.Many2one('test.plan_spending_actual',required=True) 
    available_source = fields.Float(related='source_id.available',default=0,readonly=True) 
    

    事は、私が "price_id" フィールドに基づいて "SOURCE_ID" をフィルタリングするです。 どうすれば実現できますか?

    2つのクラスは1つのxmlにあります。 XMLの一部はこのように見えます。

    <field name="relocation_line_ids"> 
        <tree editable="bottom"> 
         <field name="source_id" string="Source" /> 
         <field name="available_source" /> 
        </tree> 
    </field> 
    

    ありがとうございました。 test.plan_relocation_lineのXMLで

    答えて

    2

    <field name="source_id" domain="[('price_id', '=',parent.price_id)]" /> 
    

    は、それはあなたが...

    +0

    どういうわけか、それは動作しませんし、フィルターをしないのに役立ちます願っています。 Btw、両方のクラスに1つのXMLしかありません。私は質問を更新しました。ありがとう。 – Aurel

    +0

    これは '親'を使って動作します。ありがとう@ KbiR。 – Aurel

    関連する問題