'Date should be given in utc'

def _get_previous_dates(self, start_date=False):

    Attendance = self.env['resource.calendar.attendance']
    purchase_date = False
    delivery_date = start_date
    if (self.calendar_id and self.calendar_id.attendance_ids):
        res = self.calendar_id._schedule_days((-1), start_date, compute_leaves=True)
        if (res and (res[0][0] < start_date)):
            group_to_find = (res[0][2] and Attendance.browse(res[0][2]).group_id.id)
            delivery_date = res[0][0]
            found_date = delivery_date
            if (self.purchase_calendar_id and self.purchase_calendar_id.attendance_ids):
                while (not purchase_date):
                    found_date = (found_date + relativedelta(days=(-1)))
                    res = self.purchase_calendar_id._schedule_days((-1), found_date, compute_leaves=True)
                    for re in res:
                        group = (re[2] and Attendance.browse(re[2]).group_id.id)
                        found_date = re[0]
                        if ((not purchase_date) and ((group_to_find and (group_to_find == group)) or (not group_to_find))):
                            purchase_date = re[0]
    else:
        delivery_date = (start_date or datetime.utcnow())
    return (purchase_date, delivery_date)
