Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get previous date of date in openerp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 246
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: