Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
5723 Tampilan

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
Buang
Penulis

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

Jawaban Terbai

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


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jan 21
6101
1
Des 21
18756
1
Jun 21
3173
1
Mar 15
7954
2
Jul 22
3653