跳至内容
菜单
此问题已终结
1 回复
7809 查看

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
形象
丢弃
最佳答案

Read datetime documentation, in particulare the strptime function doc.

形象
丢弃
相关帖文 回复 查看 活动
3
9月 20
6454
1
12月 24
16746
1
1月 17
4500
4
8月 24
77112
2
5月 25
1678