This question has been flagged
1 Reply
3834 Views

hi,

we have two custom modules (ModuleA and ModuleB) that are On2Many related. (MainCategory and SubCategory)

Products have Many2One relations to ModuleA and to ModuleB.

If a user edits a Product and selects a ModuleA (MainCategory) Record the other Dropdown for ModuleB (Subcategory) should only show Subcategories that have a relation to the previously selected ModuleA (MainCategory)

how can this be achieved?

Avatar
Discard
Best Answer

Hi JAck,
I think adding domain filter may solve your problem.

Please add the below portion in your product xml view:

<field name="main_cate"/>   

<field name="sub_cate" domain="[('parent_cate', '=', main_cate)]"/>


Ensure that you defined two fields in product py file like below:

main_cate = fields.Many2one('main.cate', string="Main Category", required=True)   

sub_cate = fields.Many2one('sub.cate', string="Sub Category", required=True)


Also ensure the field name "parent_cate" is there in sub.cate model (M2o with 'main.cate')

Hope this may help you.

Avatar
Discard