Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
7706 Näkymät

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
Avatar
Hylkää
Paras vastaus

Read datetime documentation, in particulare the strptime function doc.

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
3
syysk. 20
6362
1
jouluk. 24
16638
1
tammik. 17
4423
4
elok. 24
76860
2
toukok. 25
1607