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 filter last week

Suscribirse

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

Se marcó esta pregunta
11 Respuestas
20479 Vistas
Avatar
Tekse Arpad

I want to filter last week. I mean if today is Monday, I want to have the date between last week's Monday to last week's Friday, and if today is Tuesday I want to have also the date between last week's Monday to last week's Friday.

I looked at python relativedelta and I succeded the following in python:

datetime.now()+ relativedelta(weeks=-1, weekday=MO)
datetime.now()+ relativedelta(weeks=-1, weekday=FR)

But I can't adapt to openerp v7. I tried with numbers instead of MO, FR, but no success. Please help me.

Thanks, TArpi

1
Avatar
Descartar
Prakash

http://help.openerp.com/question/20731/creating-this-week-or-today-7-days-filter/

Tekse Arpad
Autor

Thanks prakash! I saw that post, but that is about "today and 7 days", but I need last week no matter the day we are in this week. I mean I need the date of last week's monday and last week's friday, if we are on today, or tomorrow or so on (in this week). I hope I made myself clear. Sorry for my english. Thanks. TArpi

Tekse Arpad
Autor

Any answer?

Avatar
Nicolas PIGANEAU
Mejor respuesta

Try the web_relativedelta module from OCA: https://github.com/OCA/web/tree/7.0/web_relativedelta.

This module brings the "weekday" parameter of relativedelta to work as expected in views and the following code to work:

<filter string="Last week" domain="[('date_order', '&gt;=', ((context_today()+relativedelta(weeks=-2,                                                                                       days=1, weekday=0)).strftime('%%Y-%%m-%%d'))),
                                                                        ('date_order', '&lt;=', ((context_today()+relativedelta(weeks=-1,                                                                                         weekday=6)).strftime('%%Y-%%m-%%d')))]"/>

Note that last monday is (weeks=-2, days=1, weekday=0) and not (week=-1, weekday=0) which would give monday of this week.

4
Avatar
Descartar
Yogesh

Thanks Nicolas !!

Avatar
Ashif Abdulrahman
Mejor respuesta

try this

<filter icon="terp-go-week"
 string="Last 7 Days"
 domain="[('create_date','<',
 time.strftime('%%Y-%%m-%%d
 23:59:59')),('create_date','>=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d
00:00:00'))]"/>
2
Avatar
Descartar
Tekse Arpad
Autor

Thanks, but this is about "the past 7 days" but I need last (past) week, no matter if today is Monday, or Tuesday, etc.

Avatar
Ahmed Mohamed Abdelmohsen Sherby
Mejor respuesta

You Can easily add or subtract number of days  , this is an example works with me:

[('x_id_exp_date','<',(context_today()+relativedelta(days=30)).strftime('%%Y-%m-%d'))]


so for your case you can do like this :

[('x_id_exp_date','<',(context_today()+relativedelta(days=-7)).strftime('%%Y-%m-%d'))]

0
Avatar
Descartar
Ahmed Mohamed Abdelmohsen Sherby

so for your case you can do like this :

[('x_id_exp_date','<',(context_today()+relativedelta(days=-7)).strftime('%%Y-%m-%d'))]

Avatar
Prakash
Mejor respuesta

Based on your python code the below code will adapt in openerp xml file

In python,

weekday=0 is equal to Monday 
weekday=4 is equal to Friday

Xml File

<filter icon="terp-document-new" string="Last weeK" name="flastweek"
 domain="[('date_order','&gt;=',((context_today() 
- relativedelta(weekday=0, weeks=-1)).strftime('%Y-%m-%d'))),
  ('date_order','&lt;=',((context_today() 
- relativedelta(weekday=4, weeks=-1)).strftime('%Y-%m-%d')))]"
/>
0
Avatar
Descartar
Tekse Arpad
Autor

Thanks, but unfortunately the weekday isn't functioning in Oerp 7. As seen here: http://help.openerp.com/question/27660/weekday-does-not-work-in-relativedelta/ and here: http://stackoverflow.com/questions/22062960/openerp-search-view-how-to-get-current-date-weekday

Avatar
Prakash
Mejor respuesta

Try the below code in openerp xml file:-

<filter icon="terp-document-new" string="Last week" name="flastweek"
domain="[('date_order','&gt;=', ((context_today()  + relativedelta(days=-1, weeks=-1)).strftime('%Y-%m-%d'))),
         ('date_order','&lt;=', ((context_today()  + relativedelta(days=3, weeks=-1)).strftime('%Y-%m-%d')))
        ]"/>
-1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

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

Registrarse
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