Skip to Content
Menu
This question has been flagged
2043 Views

hi all,

a problem to solve, when user selected (Many2one) a category i need to find a parent_id for which we have a static name like 'Brands' to add domain filter on another field to have related underlying/child categories of Brands.


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 and system should populate on Electronics related Brands to select from.

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

another Many2one field brand_id will should populate with last 2 and other like-wise entries (All / Electronics / related Brands) which are child of All / Electronics / Brands.

there are more Brands in this model like:

All / Foods / Brands

All / Services / Brands

etc.

please help, how i can do it.


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")

regards

Avatar
Discard
Author

no hope? i asked wrong question? please help how i can do this or at least inform that it is not possible...

Related Posts Replies Views Activity
2
Apr 23
1454
2
May 24
35825
2
Nov 22
1483
1
Feb 22
6687
2
Dec 21
2715