Sunday, 10 August 2014

Odoo/ OpenERP: Calculate difference between two dates

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta

date_format = '%Y-%m-%d'

joining_date = '2013-08-23'
current_date = (

d1 = datetime.strptime(joining_date, date_format).date()
d2 = datetime.strptime(current_date, date_format).date()
r = relativedelta(d2,d1)

print r.years
print r.months
print r.days

Thanks!!!!!!!!! Enjoy Programming :)


  1. Interesting! I'm looking for something similar but just for minutes. I've created a datetime field that I populate with trough a server action linked to a button and now I would like to compute the minutes that passed to complete an order using the date_order field as source on pos.order model. Can you tell me how should I edit your syntax? Thanks!

  2. To find the desired results you have to convert both the dates in minutes. Better you check here:

    Check "Ken Cochrane's " answer. It will fix your thing.

    1. Yes! Exactly what I need! Thanks!


Thanks for your valuable comments.

Odoo 10: Close wizard and open standard form

Hi, Today we are going to learn how to open standard form after saving data in wizard. Let's say I have created an wizard to fill bas...