Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- today = datetime.datetime.now()
- context_today = datetime.datetime.now().date
- today_domain = ['&',("x_studio_date", ">=", (context_today().strftime('%Y-%m-%d'))), ("x_studio_date", "<=", (context_today().strftime('%Y-%m-%d')))]
- bookings = 'x_bookings'
- filter_delete = env['ir.filters'].search([("model_id","=","x_bookings")])
- for f in filter_delete:
- f.unlink()
- weekdays = {
- 0 : "Monday",
- 1 : "Tuesday",
- 2 : "Wednesday",
- 3 : "Thursday",
- 4 : "Friday",
- 5 : "Saturday",
- 6 : "Sunday"
- }
- for n in range(0,8):
- day = today + datetime.timedelta(days=n)
- weekday = day.weekday() #0 - 6
- day_num = day.strftime("%y-%m-%d")
- day_str = str(day_num)
- domain = ['&',("x_studio_date", ">=", ((context_today()+datetime.timedelta(days=n)).strftime('%Y-%m-%d'))), ("x_studio_date", "<=", ((context_today()+datetime.timedelta(days=n)).strftime('%Y-%m-%d')))]
- if weekday not in (5,6):
- weekday_name = weekdays[weekday]
- date = day_str + " " + str(weekday_name)
- if n == 0:
- date = date + " - Today"
- domain_weekday = str(domain)
- filters = env['ir.filters'].create({'name': date, 'model_id': 'x_bookings', 'domain': domain_weekday})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement