odoo python datetime.date 转datetime.datetime

odoo python datetime.date 转datetime.datetime,第1张

 File "G:\od15\odoo\http.py", line 307, in _handle_exception
    raise exception.with_traceback(None) from new_cause
TypeError: unsupported operand type(s) for -: 'datetime.date' and 'datetime.datetime'

dateobject = datetime.date.today()
datetime.datetime.combine(dateobject, datetime.time())

或者

datetime.datetime.combine(dateobject, datetime.time.min)

datetime.time()datetime.time.min都表示午夜(00:00:00)。

def _compute_milestone_progress_time(self):
    for record in self:
        time_count = (datetime.datetime.combine(record.deadline, datetime.time()) - record.planned_date_begin).days

record.deadline 为datetime.date类型 ,所以需要转换一下

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/789203.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存