diff --git a/__manifest__.py b/__manifest__.py index b5d5f55..f846dce 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -9,7 +9,7 @@ "application": False, "installable": True, "depends": [ - "website", "website_sale", "website_sale_delivery" + "website", "website_sale", "website_sale_delivery", "product_pack" ], "data": [ 'security/ir.model.access.csv', diff --git a/models/vracoop_point_retrait.py b/models/vracoop_point_retrait.py index e59b79e..57b6fd8 100644 --- a/models/vracoop_point_retrait.py +++ b/models/vracoop_point_retrait.py @@ -78,7 +78,7 @@ class VracoopPointRetrait(models.Model): ('dimanche', 6, 0, 'dim.'), ] for rec in self: - my_datetime = datetime.today() + today_datetime = datetime.today() return_slot_list = [] vals = [] exclure_days_nb = rec.vracoop_retrait_time_ids.search_count([ @@ -112,83 +112,53 @@ class VracoopPointRetrait(models.Model): hour = time_available_week.strftime("%H") minute = time_available_week.strftime("%M") interval = int(hour)*60 + int(minute) - - if week.day == my_datetime.day: - first_morning_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.first_morning_heure) - last_morning_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.last_morning_heure) - first_noon_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.first_noon_heure) - last_noon_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.last_noon_heure) - today_hour_available = my_datetime + timedelta( - hours=corresponding_line.preparation_time) - if (today_hour_available > first_morning_hour_week) and (today_hour_available < last_morning_hour_week): - dtstart_morning = today_hour_available - dtstart_noon = first_noon_hour_week - elif (today_hour_available > first_noon_hour_week) and (today_hour_available < last_noon_hour_week): - dtstart_morning = today_hour_available - dtstart_noon = today_hour_available - elif (today_hour_available > last_morning_hour_week) and (today_hour_available < first_noon_hour_week): - dtstart_morning = today_hour_available - dtstart_noon = first_noon_hour_week - else: - dtstart_morning = today_hour_available - dtstart_noon = today_hour_available - - list_slot_per_day_morning = list( - rrule( - MINUTELY, - interval=interval, - byweekday=byweekday, - dtstart=dtstart_morning, - until=last_morning_hour_week)) - list_slot_per_day_noon = list( - rrule( - MINUTELY, - interval=interval, - byweekday=byweekday, - dtstart=dtstart_noon, - until=last_noon_hour_week)) - else: - first_morning_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.first_morning_heure) - last_morning_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.last_morning_heure) - first_noon_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.first_noon_heure) - last_noon_hour_week = datetime( - week.year, week.month, week.day) + timedelta( - hours=corresponding_line.last_noon_heure) - list_slot_per_day_morning = list( - rrule( - MINUTELY, - interval=interval, - byweekday=byweekday, - dtstart=first_morning_hour_week, - until=last_morning_hour_week)) - list_slot_per_day_noon = list( - rrule( - MINUTELY, interval=interval, - byweekday=byweekday, - dtstart=first_noon_hour_week, - until=last_noon_hour_week)) + + first_morning_hour_week = datetime( + week.year, week.month, week.day) + timedelta( + hours=corresponding_line.first_morning_heure) + last_morning_hour_week = datetime( + week.year, week.month, week.day) + timedelta( + hours=corresponding_line.last_morning_heure) + first_noon_hour_week = datetime( + week.year, week.month, week.day) + timedelta( + hours=corresponding_line.first_noon_heure) + last_noon_hour_week = datetime( + week.year, week.month, week.day) + timedelta( + hours=corresponding_line.last_noon_heure) + + list_slot_per_day_morning = list( + rrule( + MINUTELY, + interval=interval, + byweekday=byweekday, + dtstart=first_morning_hour_week, + until=last_morning_hour_week)) + list_slot_per_day_noon = list( + rrule( + MINUTELY, interval=interval, + byweekday=byweekday, + dtstart=first_noon_hour_week, + until=last_noon_hour_week)) slots = [] nb_sale_slot = 0 - for slot_per_day_morning in list_slot_per_day_morning: - first_slot = slot_per_day_morning.strftime("%H:%M") - slot_per_day_morning = slot_per_day_morning + timedelta( + + 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_per_day_morning.strftime("%H:%M") - + last_slot = slot_elem_last.strftime("%H:%M") + if slot_elem.date() == today_datetime.date(): + 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( '%s.%s' % (first_slot_hour[0], first_slot_hour[1])) @@ -199,13 +169,20 @@ class VracoopPointRetrait(models.Model): if nb_sale_slot < rec.nb_max_retrait: slots.append((first_slot, last_slot)) - nb_sale_slot = 0 - for slot_per_day_noon in list_slot_per_day_noon: - first_slot = slot_per_day_noon.strftime("%H:%M") - slot_per_day_noon = slot_per_day_noon + timedelta( + 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_per_day_noon.strftime("%H:%M") - + last_slot = slot_elem_last.strftime("%H:%M") + if week.date() == today_datetime.date(): + 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( '%s.%s' % (first_slot_hour[0], first_slot_hour[1])) diff --git a/static/src/js/vracoop_retrait.js b/static/src/js/vracoop_retrait.js index 80dce0b..82103d1 100644 --- a/static/src/js/vracoop_retrait.js +++ b/static/src/js/vracoop_retrait.js @@ -54,7 +54,6 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) { var _onDayClick = function(ev) { var day_retrait = $(ev.currentTarget).val(); - console.log(day_retrait); var values = {'day_retrait': day_retrait}; dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values)) .then(_onDayUpdateAnswer); @@ -80,7 +79,6 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) { var _onHourClick = function(ev) { var hour_retrait = $(ev.currentTarget).val(); var values = {'hour_retrait': hour_retrait}; - console.log(values); dp.add(ajax.jsonRpc('/shop/update_retrait', 'call', values)) .then(_onHourUpdateAnswer); }; @@ -117,5 +115,9 @@ odoo.define('vracoop_click_and_collect.vracoop_retrait', function (require) { var $carriers = $("#delivery_carrier input[name='delivery_type']"); $carriers.click(_onCarrierClick2); + + if ($carriers.length > 0) { + $carriers.filter(':checked').click(); + } }); diff --git a/views/vracoop_templates.xml b/views/vracoop_templates.xml index 18a055f..e4b2510 100644 --- a/views/vracoop_templates.xml +++ b/views/vracoop_templates.xml @@ -28,7 +28,7 @@