如何计算OpenERP中两个日期之间的差异? [英] How to calculate the difference between two dates in OpenERP?
本文介绍了如何计算OpenERP中两个日期之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的自定义模块中,我无法计算两个日期之间的差值.
In my custom module I am unable to calculate difference between two dates.
我的字段是
'date_s':fields.datetime('Start Date'),
'date_e':fields.datetime('End Date'),
我想在工期字段中自动计算差异:
I want to calculate the difference automatically in my duration field:
'Duration':fields.char('Duration'),
推荐答案
这是我编写的一个简单函数.希望对您有帮助.
this is a simple function I have written. Hope it will help you.
def onchange_return_date(self, cr, uid, ids, issuedate, returndate):
a=datetime.strptime(issuedate,"%Y-%m-%d")
b=datetime.strptime(returndate,"%Y-%m-%d")
timedelta = b - a
diff=timedelta.days
return {'value': {'days':diff}}
这篇关于如何计算OpenERP中两个日期之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文