|
|
@ -2,6 +2,7 @@ |
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
from odoo import models, fields, api |
|
|
|
import pytz |
|
|
|
# import dateutil.rrule as rrule |
|
|
|
# from datetime import date |
|
|
|
from dateutil.relativedelta import * |
|
|
@ -10,6 +11,7 @@ from dateutil.rrule import rrule, DAILY, MINUTELY, rruleset |
|
|
|
from dateutil.parser import * |
|
|
|
# from datetime import * |
|
|
|
from datetime import datetime, timedelta |
|
|
|
from pytz import timezone |
|
|
|
|
|
|
|
class VracoopPointRetrait(models.Model): |
|
|
|
_name = "vracoop.point.retrait" |
|
|
@ -78,7 +80,19 @@ class VracoopPointRetrait(models.Model): |
|
|
|
('dimanche', 6, 0, 'dim.'), |
|
|
|
] |
|
|
|
for rec in self: |
|
|
|
today_datetime = datetime.today() |
|
|
|
|
|
|
|
today_datetime_utc = datetime.now(timezone('UTC')) |
|
|
|
today_datetime2 = today_datetime_utc.astimezone(timezone('Europe/Berlin')) |
|
|
|
|
|
|
|
today_datetime = datetime( |
|
|
|
today_datetime2.year, |
|
|
|
today_datetime2.month, |
|
|
|
today_datetime2.day, |
|
|
|
today_datetime2.hour, |
|
|
|
today_datetime2.minute, |
|
|
|
today_datetime2.second) |
|
|
|
|
|
|
|
# today_datetime = datetime.strptime(today_datetime2, "%Y-%m-%d %H:%M:%S") |
|
|
|
return_slot_list = [] |
|
|
|
vals = [] |
|
|
|
exclure_days_nb = rec.vracoop_retrait_time_ids.search_count([ |
|
|
@ -144,20 +158,23 @@ class VracoopPointRetrait(models.Model): |
|
|
|
|
|
|
|
today_hour_available = today_datetime + timedelta( |
|
|
|
hours=corresponding_line.preparation_time) |
|
|
|
|
|
|
|
for slot_elem in list_slot_per_day_morning: |
|
|
|
first_slot = slot_elem.strftime("%H:%M") |
|
|
|
slot_elem_last = slot_elem + timedelta( |
|
|
|
hours=corresponding_line.availability_time) |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem >= last_morning_hour_week: |
|
|
|
continue |
|
|
|
|
|
|
|
if slot_elem.date() == today_datetime.date(): |
|
|
|
if (slot_elem_last > last_morning_hour_week): |
|
|
|
if (today_hour_available > last_morning_hour_week): |
|
|
|
continue |
|
|
|
if (today_hour_available > slot_elem_last): |
|
|
|
continue |
|
|
|
if slot_elem_last >= last_morning_hour_week: |
|
|
|
slot_elem_last = last_morning_hour_week |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem >= last_morning_hour_week: |
|
|
|
continue |
|
|
|
# Check number of maximum withdrawal not reached |
|
|
|
first_slot_hour = first_slot.split(":") |
|
|
|
first_slot_float = float( |
|
|
@ -168,20 +185,26 @@ class VracoopPointRetrait(models.Model): |
|
|
|
('hour_retrait', '=', first_slot_float)]) |
|
|
|
if nb_sale_slot < rec.nb_max_retrait: |
|
|
|
slots.append((first_slot, last_slot)) |
|
|
|
|
|
|
|
|
|
|
|
for slot_elem in list_slot_per_day_noon: |
|
|
|
first_slot = slot_elem.strftime("%H:%M") |
|
|
|
slot_elem_last = slot_elem + timedelta( |
|
|
|
hours=corresponding_line.availability_time) |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if week.date() == today_datetime.date(): |
|
|
|
if slot_elem >= last_noon_hour_week: |
|
|
|
continue |
|
|
|
|
|
|
|
if slot_elem.date() == today_datetime.date(): |
|
|
|
if (slot_elem_last > last_noon_hour_week): |
|
|
|
if (today_hour_available > last_noon_hour_week): |
|
|
|
continue |
|
|
|
if (today_hour_available > slot_elem_last): |
|
|
|
continue |
|
|
|
|
|
|
|
if slot_elem_last >= last_noon_hour_week: |
|
|
|
slot_elem_last = last_noon_hour_week |
|
|
|
last_slot = slot_elem_last.strftime("%H:%M") |
|
|
|
if slot_elem >= last_noon_hour_week: |
|
|
|
continue |
|
|
|
|
|
|
|
# Check number of maximum withdrawal not reached |
|
|
|
first_slot_hour = first_slot.split(":") |
|
|
|
first_slot_float = float( |
|
|
|