Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Help with Combining Two group_by Fields in a Single Filter (Odoo 17)

Naroči se

Get notified when there's activity on this post

This question has been flagged
filter17.0odoo 17
2 Odgovori
1426 Prikazi
Avatar
Salka TALEB

Bonjour à tous,

Je travaille avec Odoo 17 et j'essaie de créer un filtre qui regroupe les enregistrements par write_date et stage_id . Cependant, je rencontre des problèmes de syntaxe dans la balise <filter> .

Lorsque j'essaie d'utiliser une liste dans l'attribut de contexte comme ceci :

xml

Modificateur de copieur

< filter string = "État de la semaine" name = "group_week_state" context = "{'group_by': ['write_date', 'stage_id']}" />

Je reçois une erreur indiquant que l'attribut de contexte doit être une chaîne et non une liste Python.

Si j'essaie de le transmettre sous forme de chaîne séparée par des virgules à la place :

xml

Modificateur de copieur

< filter string = "État de la semaine" name = "group_week_state" context = "{'group_by': 'write_date,stage_id'}" />

Il applique uniquement le regroupement par write_date et ignore stage_id .

Quelqu'un a-t-il réussi à appliquer plusieurs champs group_by dans un seul filtre dans Odoo 17 ? J'apprécierais toute aide ou solution de contournement.

Merci d'avance!


0
Avatar
Opusti
Salka TALEB
Avtor

Thank you very much, christoph your response was exactly what i need thank you very much, and big thank you to cybrosys

Avatar
Christoph Farnleitner
Best Answer

Only known way to combine multiple fields in a predefined group_by is by defining a record for the ir.filters model.

This is also the only case in which Odoo combines two or more fields in a group_by in the UI by default that can be select by a user*. See for example https://github.com/odoo/odoo/blob/17.0/addons/account/report/account_invoice_report_view.xml#L61

To apply this approach, for example on the res.partner model, you would do the following:

view/res_partner_views.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <record id="filter_country_salesperson_group" model="ir.filters">
        <field name="name">By Country and Salesperson</field>
        <field name="model_id">res.partner</field>
        <field name="domain">[]</field>
        <field name="user_id" eval="False"/>
        <field name="context">{'group_by': ['country_id', 'user_id']}</field>
    </record>
</odoo>

Which would result in a filter stored as a favorite:


... and is essentially the same what Odoo does for example in the Invoicing App (technical name account):


A direct integration into the Group By-section does not seem to be possible.

If you want to prevent users from deleting (or changing) this particular filter (which could be easily done, since its a filter stored as a favorite just like any other) you could do a super().write() and super().unlink() extension checking for this particular record and raise an UserError when an attempt on changing or deleting is detected.



*) You can pass multiple pre-defined group_by filters when using a dedicated action, but according to your question and example source, this is not what you are looking for.

1
Avatar
Opusti
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


In Odoo, the <filter> tag's context attribute must be a valid Python dictionary string, and the 'group_by' key can only accept a single field name (string), not a list of fields, even though Odoo's ORM supports grouping by multiple fields in backend code.


Try with any of the following.


1: Use the web UI (manual grouping)

          Just advise your users to manually group by both fields using the “Group By” > “Add Custom Group” option in the search view. This is the safest option if you want to avoid custom modules.


 2: Predefine a custom action (server-side context)

          You can create a custom ir.actions.act_window that pre-sets multiple group_by fields using Python:

              {

    'name': 'Group by Write Date and Stage',
'type': 'ir.actions.act_window',
'res_model': 'your.model',
'view_mode': 'tree,form',
'context': {
'group_by': ['write_date', 'stage_id'],
},
}


This works in server-side Python because the 'group_by' can be a list in that context.

Then link to this action from a menu item.


Hope it helps

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Leave request
Community 17.0 odoo 17
Avatar
Avatar
1
jun. 25
1354
How to set a field as default for the Add Custom Filter option in Odoo 17 or 18 ?
filter default 17.0
Avatar
Avatar
1
jan. 25
2212
Hide empty groups in list view
filter listview group_by 17.0
Avatar
0
avg. 24
224
in POS orderline is it possible to add background color to the discounted product line
17.0
Avatar
Avatar
1
nov. 25
267
cbbbbggf
filter
Avatar
0
nov. 25
2
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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