Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

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

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
filter17.0odoo 17
2 Réponses
1438 Vues
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
Ignorer
Salka TALEB
Auteur

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
Meilleure réponse

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
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

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
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Leave request
Community 17.0 odoo 17
Avatar
Avatar
1
juin 25
1356
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
janv. 25
2224
Hide empty groups in list view
filter listview group_by 17.0
Avatar
0
août 24
224
in POS orderline is it possible to add background color to the discounted product line
17.0
Avatar
Avatar
1
nov. 25
269
cbbbbggf
filter
Avatar
0
nov. 25
2
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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