Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
7812 Widoki

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
Awatar
Odrzuć
Najlepsza odpowiedź

Read datetime documentation, in particulare the strptime function doc.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
3
wrz 20
6457
1
gru 24
16747
1
sty 17
4508
4
sie 24
77118
2
maj 25
1683