I've encountered strange behaviour of a one2many field in Odoo.
This is my code:
models.py:
class mrp_bom_inherit(models.Model):
_inherit = 'mrp.bom'
producten_tussenmodel = fields.One2many(comodel_name='tussenmodel_wc_producten', inverse_name='bom_id', string="producten", copy=True)
class tussenmodel_wc_producten(models.Model):
bom_id = fields.Integer()
routing_id = fields.Integer()
producten = fields.Char(string="Productnr.")
views.xml:
<field name="producten_tussenmodel" widget="one2many_list" nolabel="1">
<tree string="Een Naar Veel" editable="bottom">
<field name="producten" domain="[('routing_id', '=', 32)]"/>
</tree>
</field>
This gives as output:
But it should only show "bbb" since "bbb" is the only record in the database with routing_id = 32 in table tussenmodel_wc_producten and bom_id in table tussenmodel_wc_producten equals an id in mrp.bom.
I've checked this via an SQL query:
select producten
from mrp_bom as m JOIN tussenmodel_wc_producten as t ON(m.id = t.bom_id)
where t.routing_id = 32
Which has as only output "bbb".
What am I doing wrong here?