0

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 Answers1

0

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.

Charif DZ
  • 14,415
  • 3
  • 21
  • 40
  • thank you for reply. I solved the problem. while I create onchange method, I wrote somthing wrongly. Now it is running rightly. Keeping in a m2m field, can be good solution. but now, I dont have to use it. thanks a lot. – Büşra Çam Jul 28 '17 at 07:57
  • Using one2many field when you fill the first record and affect the same products to the second record you will lose them in the first one. Did that happen to you – Charif DZ Jul 28 '17 at 10:06