Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
7779 Vizualizări

I am trying to work with the due date in account.invoice, i want the difference of current date an date_due but i get this error. ValueError: time data 'inv.date_due' does not match format '%m-%d-%Y %H:%M:%S'

my code is:

def _get_date_difference(self, cr, uid, ids, field_name, arg,context):
        res={}
        for inv in self.browse(cr,uid,ids):            
            dt=datetime.strptime('inv.date_due', '%m-%d-%Y %H:%M:%S').date()
##            if inv.payment_term and inv.state == "open":
            res[inv.id] = abs((datetime.now()-dt).days)
        return res
Imagine profil
Abandonează
Cel mai bun răspuns

Read datetime documentation, in particulare the strptime function doc.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
3
sept. 20
6419
1
dec. 24
16723
1
ian. 17
4486
4
aug. 24
77015
2
mai 25
1656