1
votes

So I have this 2 classes.

this

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')

and this

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)

The thing is I want to filter the "source_id" based on the "price_id" field. How can I achieve that?

The 2 classes are in one xml. A part of the xml looks like this.

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

Thank you so much for your help.

1

1 Answers

3
votes

in xml of test.plan_relocation_line:

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

Hope it will help you..