In openerp first install the resource module and inherit the object of resource.calendar and If no calendar is provided, just return the previous day and day of a resource.calendar. If calendar resource is no given simply remove one day from the submitted date and calender and previous day of calendar.
For this use below code in your own module in .py file,
def get_previousday(self, cr, uid, id, day_date, context=None):
if not id:
return day_date + relativedelta(days=-1)
weekdays = self.get_weekdays(cr, uid, id, context)
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)
0 Comment(s)