使用Odoo10,我需要计算两个日期时间类型,开始和结束字段之间的差异,我需要差异在分钟。我该怎么做?
答案 0 :(得分:0)
试试这个例子:
from dateutil.relativedelta import relativedelta
@api.one
@api.depends('start_field','finish_field')
def _total_minutes(self):
if self.start_field and self.finish_field:
start_dt = fields.Datetime.from_string(self.start_field)
finish_dt = fields.Datetime.from_string(self.finish_field)
difference = relativedelta(finish_dt, start_dt)
days = difference.days
hours = difference.hours
minutes = difference.minutes
seconds = 0