'Get previous date of day_date, based on resource.calendar. If no
calendar is provided, just return the previous day.
:param date day_date: current day as a date
:return date: previous day of calendar, or just previous day'

@api.multi
def get_previous_day(self, day_date):

    if (not self):
        return (day_date + relativedelta(days=(-1)))
    self.ensure_one()
    weekdays = self.get_weekdays()
    weekdays.reverse()
    base_index = (-1)
    for weekday in weekdays:
        if (weekday < day_date.weekday()):
            break
        base_index += 1
    new_index = ((base_index + 1) % len(weekdays))
    days = (weekdays[new_index] - day_date.weekday())
    if (days > 0):
        days = (days - 7)
    return (day_date + relativedelta(days=days))
