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

How to filter a domain view with a function? In odoo 9

Suscribirse

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

Se marcó esta pregunta
domainviewdomain_filterodoo9
1 Responder
17485 Vistas
Avatar
Baintex Technologies S.L.

I want to filter a domain with a function instead of a variable in order to show only some registers in the view.

I have done this:

 

 class SaleOrderExt(models.Model):
  _inherit = ['sale.order']
  @api.multi
  def custom_funct_date(self):
   my_date = ... (some stuff)
   return my_date

Then, in the view, I have filtered the domain:

 

    <?xml version="1.0"?>
    <openerp>
      <data>
        <record id='action_menu_custom_date' model='ir.actions.act_window'>
          <field name="name">This is a test</field>
          <field name="res_model">sale.order</field>
          <field name="view_type">form</field>
          <field name="view_mode">tree,form</field>
          <field name="domain">[('date_order','>=',custom_funct_date)]</field>
        </record>
      </data>
    </openerp>

But this is giving me an error:

    ValueError: "name 'custom_funct_date' is not defined" while evaluating
    u"[('date_order','>=',custom_funct_date)]"
0
Avatar
Descartar
Avatar
Divya-vyas
Mejor respuesta

Hello

I suggest you to add one more field which is compute field. and then pass in domain. use custom_funct_date method in that new compute field.


1
Avatar
Descartar
Baintex Technologies S.L.
Autor

Okay, I have tried this too: my_date = fields.Datetime(string="Computed date", compute="custom_funct_date")

But it gives me that error: ValueError: "name 'my_date' is not defined" while evaluating u"[('date_order','>=', my_date)]"

Divya-vyas

it's wrong syntax.

try this one.

"[('date_order','>=', 'my_date')]"

Divya-vyas

also add my_date on view file and set invisible = 1

Baintex Technologies S.L.
Autor

DataError: invalid input syntax for type timestamp: "my_date"

LÍNEA 1: ...ids"."res_id") AND (("sale_order"."date_order" >= 'my_date...

Divya-vyas

did you add field in form view?

Baintex Technologies S.L.
Autor

I think so. In my custom view, the field appears (if I quit the part of invisible).

Divya-vyas

make sure your compute function return proper date format like sale_order.date_order,

try also without ('date_order','>=', my_date)

Divya-vyas

*with ('date_order','>=', my_date)

Baintex Technologies S.L.
Autor

Checked and same result :(

Baintex Technologies S.L.
Autor

I think that if I put this:

('date_order','>=', my_date)

my_date is treated as a variable, and that variable doesn't exist.

If I put:

('date_order','>=', 'my_date')

'my_date' is treated as a string, and gives an error, because a string doen't have a datetime type

salah BELHAMICHE

Any solution For this problem ? i have the same use case.

Baintex Technologies S.L.
Autor

Look at this:

https://stackoverflow.com/questions/43733825/how-to-filter-a-domain-view-with-a-function-in-odoo-9

¿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
How can I pass more than one field to a search function? In Odoo 9 Resuelto
domain view search domain_filter odoo9
Avatar
Avatar
Avatar
Avatar
6
sept 20
20765
Condition Drop Down Items
domain domain_filter
Avatar
0
feb 25
18
[odoo 11] A problem of domain as strings on xml file Resuelto
domain view
Avatar
Avatar
Avatar
2
may 18
5221
How can I use domain filter with a function to hide lines in a treeview in odoo 9?
filter domain domain_filter function_field odoo9
Avatar
Avatar
Avatar
2
sept 16
8655
how to access another models fields from view (xml) file
domain view
Avatar
Avatar
Avatar
2
mar 15
13461
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.

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