Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Group by function / computed field with out ==> “store = True” in odoo 11

Odoberať

Get notified when there's activity on this post

This question has been flagged
python3odoo11communityodoo11.0
1 Odpoveď
14436 Zobrazenia
Avatar
Saloua.sahnoune

I want to group by computed field (type_client).

I know that I should make it store = True, but I cannot because the values ​​are dynamic. Is there another option?

This is my function:


def act_show_supect(self):
    for objctf in self:
        for client in self.env['res.partner'].search([('user_id.id', '=', self.user_id.id),
                                                      ('company_type', '=', 'company'),
                                                      ('type_client', '=', 'suspect')]):
            if client.type_client == 'suspect':
                objctf.ensure_one()
                res = objctf.env['ir.actions.act_window'].for_xml_id(
                    'base', 'action_partner_form')
                res.update(
                    context=dict(
                        objctf.env.context,
                        search_default_user_id_id=objctf.user_id.id,
                        search_default_type_client='suspect',
                    ),
                    domain=[('user_id.id', '=', objctf.user_id.id),
                            ('company_type', '=', 'company'),
                            ('type_client', '=', 'suspect')]
                )

                return res

And this is the error after execution:

File "E:\odoo11.0\odoo\models.py", line 1908, in read_group
    result = self._read_group_raw(domain, fields, groupby, offset=offset, 
    limit=limit, orderby=orderby, lazy=lazy)

  File "E:\odoo11.0\odoo\models.py", line 1946, in _read_group_raw
    assert gb_field.store and gb_field.column_type, "Fields in 'groupby' 
    must be regular database-persisted fields (no function or related 
    fields), or function fields with store=True"

  AssertionError: Fields in 'groupby' must be regular database-persisted 
    fields (no function or related fields), or function fields with 
    store=True

And i want to group by:

('type_client', '=', 'suspect')

3
Avatar
Zrušiť
Avatar
faOtools
Best Answer

 Group by, filters, searches assume to work only with storable fields, since such operations assume direct queries to database. If a field is not stored, it is not kept in a database. So, a simple answer is no, it is not possible.

What you can do:

  1. To prepare a cron, which would calculate your fields regularly. So, it would be stored fields. The drawback is obvious: in such a case it would not be a computed field, it would not be calculated in real time. Thus, there might be obsolescent data which is not yet updated

  2. To implement a wizard, where you would re-calculate your fields and after that open a view with groupings (or a report). I guess, it is the most efficient approach, since would not mislead users.

  3. To  re-write methods of the models.py which relate to search and groupings. Also you can experiment with a 'search' attribute of the field and related search methods. It would be a really difficult task, and, in the most cases, would lead to performance slowdowns.



2
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
when generating payslip i got this error Solved
odoo11community odoo11.0
Avatar
Avatar
1
feb 21
4357
How to programatically move file from i.attachment to specific directory
odoo11community odoo11.0
Avatar
0
jún 20
3317
make my function work forever
python3 odoo11.0
Avatar
Avatar
1
jan 20
3688
add python function to specific action
python3 odoo11.0
Avatar
0
jan 20
3973
valid logged in user
python3 odoo11.0
Avatar
Avatar
1
dec 19
4785
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now