Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5727 Zobrazení

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
Zrušit
Autor

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

Nejlepší odpověď

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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
led 21
6105
1
pro 21
18778
1
čvn 21
3173
1
bře 15
7958
2
čvc 22
3656