Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5743 Widoki

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...

Awatar
Odrzuć
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

Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sty 21
6126
1
gru 21
18807
1
cze 21
3206
1
mar 15
7966
2
lip 22
3682