Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

dependent Dropdowns

By
Jack
on 11/3/16, 11:25 AM 117 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?

2

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 11/4/16, 12:59 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/3/16, 11:25 AM
Seen: 117 times
Last updated: 11/8/16, 5:25 AM