Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
filter17.0odoo 17
2 Respuestas
1437 Vistas
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
Descartar
Salka TALEB
Autor

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
Mejor respuesta

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
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

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
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Leave request
Community 17.0 odoo 17
Avatar
Avatar
1
jun 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
ene 25
2223
Hide empty groups in list view
filter listview group_by 17.0
Avatar
0
ago 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
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

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