Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to display all dates between two dates ?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
6 Risposte
18073 Visualizzazioni
Avatar
Undan

When two dates are given for eg: start date-: 05/01/2016 end date : 05/03/2016 ..from january to march ..i want to display all the dates between these two dates.

0
Avatar
Abbandona
Avatar
Anil Kesariya
Risposta migliore

Undan,

Here you Go!

import datetime
t_date = datetime.datetime.today()
num_of_day = 10 # This is different between two date range, you just find difference and use as numb_of_day

date_list = [base - datetime.timedelta(days=x) for x in range(0, num_of_day)]
print "Day List in Datetime Format:",date_list

This might help you,

Regards,

Anil.

4
Avatar
Abbandona
Avatar
iWesabe Technologies
Risposta migliore




def dates_between_str_dates(self, date1, date2, mode='date'):
    date_from = fields.Date.from_string(date1)
 date_to = fields.Date.from_string(date2)
 
delta = date_to - date_from

 if delta.days < 0:
    return None

res = []
    
    for n in range(delta.days + 1):
       if mode == 'date':
           res.append(date_from + timedelta(days=n))
       if mode == 'string':
          res.append(fields.Date.to_string(date_from + timedelta(days=n)))
return res 

Add this function. Parameter mode is to specify output type string/date.   

Thanks !

iWesabe

1
Avatar
Abbandona
Linita Abraham

hi, in XML report, how can I display all the dates in that range(start_date to end_date)?

iWesabe Technologies

You can call python function from Qweb Like ..

<tr t-foreach="o.dates_between_str_dates(o.date_from,o.date_to)" t-as="each_date">

Linita Abraham

Thank you so much..This was so helpful.

Linita Abraham

Hi, any idea how to display net sales for each day in the report

orders = self.env['pos.order'].search([('date_order', '>=', docs.date_from),

('date_order', '<=', docs.date_to)])

for order in orders:

net_sales += order.amount_total

but in xml report,for me it is displaying the total net sales of that range in all dates of that range,but i want to display net_sales per date.How can i display net sales per date?

Thanks in advance

Avatar
Deepak
Risposta migliore
 
fmt = '%Y-%m-%d'
d1 = datetime.strptime(from_date, fmt)
d2 = datetime.strptime(to_date, fmt)
dates_btwn = d1
while dates_btwn <= d2:   
    print "dates_between=========>>>",dates_btwn.date()
    dates_btwn = dates_btwn + relativedelta.relativedelta(days=1)

This will display the dates between two dates..Hope this will help You..

1
Avatar
Abbandona
Avatar
Tarek Mohamed Ibrahim
Risposta migliore

use the following function, it is based on using the 'timedelta' 


from datetime import datetime, timedelta

#show dates between two dates

def get_date_list(date1, date2):

    date_list = []

    loop_dt = date1

    print loop_dt

    while loop_dt < date2:

        loop_dt = loop_dt + timedelta(days=1)

        print loop_dt


get_date_list( datetime(2016,1,5), datetime(2016,03,5))


you can change it to return a list of dates

1
Avatar
Abbandona
Avatar
Hetashree Chauhan (hch)
Risposta migliore

import datetime

today = datetime.datetime.today()

numdays = 10

date_list = [today - datetime.timedelta(days=x) for x in range(0, numdays)]

print 'date_list',date_list

0
Avatar
Abbandona
Avatar
Neha Patel (nat)
Risposta migliore

from datetime import date, timedelta as td

dt1 = date(2016, 7, 10)

dt2 = date(2016, 7, 19)

delta = dt2 - dt1

for i in range(delta.days + 1):

    print dt1 + td(days=i)



i hope it might help you

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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