Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • e-learning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar 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
  • Proyecto
  • 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

How to filter and group by pricelist on res.partner?

Suscribirse

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

Se marcó esta pregunta
v15odoo16features
3 Respuestas
3955 Vistas
Avatar
Odoo learner

I need to be able to filter and group by pricelist on contacts, The technical field name is '

property_product_pricelist = fields.Many2one(
comodel_name='product.pricelist',
string="Pricelist",
compute='_compute_product_pricelist',
inverse="_inverse_product_pricelist",
company_dependent=False,
domain=lambda self: [('company_id', 'in', (self.env.company.id, False))],
help="This pricelist will be used, instead of the default one, for sales to the current partner")

'

I am afraid that if I add store=True, it would break something in Odoo. I'm not sure

0
Avatar
Descartar
Avatar
Ayoub Chaibi
Mejor respuesta

you can do it with partner search module provided by OCA

https://apps.odoo.com/apps/modules/17.0/partner_pricelist_search

1
Avatar
Descartar
Avatar
D Enterprise
Mejor respuesta

Hiii,

To make a field searchable (filterable or groupable in the UI), it must be stored in the database . So yes, to enable filtering/grouping by pricelist, you must add store=True :

property_product_pricelist = fields.Many2one(

    comodel_name='product.pricelist',

    string="Pricelist",

    compute='_compute_product_pricelist',

    inverse="_inverse_product_pricelist",

    store=True,

    company_dependent=False,

    domain=lambda self: [('company_id', 'in', ( self.env.company.id , False))],

    help="This pricelist will be used, instead of the default one, for sales to the current partner"

)


Will store=True Break Anything?
In most cases — no , as long as:

  1. The compute method is always valid and gives a consistent result .
  2. You have an inverse method (which you do: _inverse_product_pricelist ).
  3. You're not depending on live computation for transient values (not true here).

This is a perfect case to use store=True :

  • It improves performance (no live compute needed on every record access)
  • It enables proper filtering & grouping
  • Odoo's default behavior is to store fields like this unless explicitly meant to be dynamic

i hope it is use full

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,

If you want to filter and group by property_product_pricelist on res.partner without storing the field, you need to define a _search method in Python. This tells Odoo how to search on a non-stored computed field, so it can be used in search views for filters and group_by.


Please refer to the code below:


from odoo import models, fields, api


class ResPartner(models.Model):

    _inherit = 'res.partner'


    property_product_pricelist = fields.Many2one(

        comodel_name='product.pricelist',

        string="Pricelist",

        compute='_compute_product_pricelist',

        inverse="_inverse_product_pricelist",

        search='_search_property_product_pricelist',  # Enable filter/group_by

        company_dependent=False,

        domain=lambda self: [('company_id', 'in', (self.env.company.id, False))],

    )


    @api.model

    def _search_property_product_pricelist(self, operator, value):

        # This assumes the pricelist is stored or linked through some relation

        return [('property_product_pricelist', operator, value)]


XML- Filter:


<record id="view_res_partner_filter" model="ir.ui.view">

       <field name="name">res.partner.search.inherit.pricelist</field>

       <field name="model">res.partner</field>

       <field name="inherit_id" ref="base.view_res_partner_filter"/>

       <field name="arch" type="xml">

           <xpath expr="//filter[@name='user_id']" position="after">

               <filter string="Pricelist" name="group_pricelist" domain="[]" context="{'group_by': 'property_product_pricelist'}"/>

           </xpath>

       </field>

   </record>


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.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How to print from Odoo on cloud server to printers in local network Resuelto
v15 odoo16features
Avatar
Avatar
Avatar
2
oct 25
5145
Understanding Automatic Deletion of Variants in Odoo When Adding New Dynamic Attributes
v15 odoo16features
Avatar
0
nov 23
2373
How I can update fullcalendar options from odoo calendar controller
v15 odoo16features
Avatar
0
oct 23
3206
Margin report based on invoice date
v15 odoo16features
Avatar
0
jul 25
7880
Running into two big problems migrating from v15 to v16
upgrade v15 odoo16features
Avatar
Avatar
1
jul 25
3231
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información 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 totalmente integrado.

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