Skip to Content
Menu
This question has been flagged
1 Reply
5648 Views

I want to, when user selected (through Many2one field from product_category) a category, I need to find its related parent_id for Brands to add a domain filter on another Many2one field to have related child entries of these Brands. As I am beginner I failed to how to do this.

Suppose Many2one field category_id here, user will select a category from first three entries, now we know that user wants to add an Electronics related item then system should populate Many2one field brand_id on Electronics related Brands (except All / Electronics / Brands) to select from below last 2 entries here in All / Electronics / Brands.

All / Electronics / Personal Computers
All / Electronics / Personal Computers / Laptop
All / Electronics / Personal Computers / Desktop
... 
...
All / Electronics / Brands
All / Electronics / Brands / HP
All / Electronics / Brands / IBM

There are more brands in this model (table data) like:

All / Foods / Brands
All / Foods / Brands / Hershey
All / Foods / Brands / Heinz
All / Foods / Brands / Oreo
...
All / Services / Brands
All / Services / Brands / IBM Garages
All / Services / Brands / Telos MNS
All / Services / Brands / Relia Quest
...

My model class is here... asking for field brand_id to filter with related Brands except the first entry of Brands in the selected category.

class OrderItems(models.Model):
    _name = 'tests.orderitems'
    _description = "Tests Order Items"
    store_id = fields.Many2one('tests.stores', string="Store", ondelete='cascade')
    order_id = fields.Many2one('tests.testsorders')
    categry_id = fields.Many2one('product.category', string="Category",
                                 domain="[['complete_name', 'not like', '%Brands%']]")
    items_id = fields.Many2one('tests.storeitems', string="Item",
                               domain="[['categs_id', '=', categry_id]]")
    brand_id = fields.Many2one('product.category', string="Brand",
                               domain="[['complete_name', 'like', '%Brands%']]")
    unit_id = fields.Many2one('tests.units', string="Unit")
    quantity = fields.Integer(string="Quantity", required=True, default=1)
    rates = fields.Float(string="Rate", default=0)
    size = fields.Char(string="Size")

please help...

Avatar
Discard
Author

why not people even says that it is not possible in odoo framework...

Because it could be done but it's not easy. Definitely not for beginners. Too complex to explain a solution without a full reproducible scenario to work and test. Perhaps hire someone for this kind of tricky stuffs

Best Answer

Same on me. Help me, please ....


Avatar
Discard
Related Posts Replies Views Activity
2
Jan 21
5975
1
Dec 21
18643
1
Jun 21
3128
1
Mar 15
7891
2
Jul 22
3623