0
votes

I'm writing a module in odoo. I hve defined some parent products and their child products. I want to do, when I'm selecting a parent product from many2one field, this parent product's childs will open in Treeview lines automatically. This tree view field is defined as one2many field.

I used onchange_parent_product funtion, also added filter according to parent_product_id.

But treeview nothing show when I select a parent product..

Please help me how can I fill treeview lines automatically ?

1

1 Answers

0
votes

to use one2many field you need many2one field in products to this new model that you create. to make it easy use many2many field it's better that way and use onchange to fill it.

just search for product that have parent_id equals to the selected product and add this record to your many2many field.

if you need to keep it using o2m field it's better to add more code to see what you did and what is the many2one field that you added in your product to your new model.