Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
filter17.0odoo 17
2 Replies
1434 Tampilan
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
Buang
Salka TALEB
Penulis

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
Jawaban Terbai

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
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

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
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
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
2220
Hide empty groups in list view
filter listview group_by 17.0
Avatar
0
Agu 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
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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