Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
5848 Vues

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
Ignorer
Auteur

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

Meilleure réponse

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


Avatar
Ignorer
Publications associées Réponses Vues Activité
2
janv. 21
6221
1
déc. 21
18882
1
juin 21
3234
1
mars 15
8027
2
juil. 22
3723