@@ -310,7 +310,7 @@ def update_order_positions_product(self, production_plan_product):
310
310
positions .update (product = production_plan_product )
311
311
312
312
@classmethod
313
- def get_next_production_day (cls , user ):
313
+ def get_production_day (cls , user ):
314
314
today = datetime .now ().date ()
315
315
production_day_next = ProductionDayProduct .objects .filter (
316
316
is_published = True , production_day__day_of_sale__gte = today
@@ -323,6 +323,30 @@ def get_next_production_day(cls, user):
323
323
return production_day_next .production_day
324
324
return None
325
325
326
+ def get_next_production_day (self , user ):
327
+ production_day_next = ProductionDayProduct .objects .filter (
328
+ is_published = True , production_day__day_of_sale__gt = self .day_of_sale
329
+ )
330
+ production_day_next = production_day_next .available_to_user (user )
331
+ production_day_next = production_day_next .order_by (
332
+ "production_day__day_of_sale"
333
+ ).first ()
334
+ if production_day_next :
335
+ return production_day_next .production_day
336
+ return None
337
+
338
+ def get_prev_production_day (self , user ):
339
+ production_day_next = ProductionDayProduct .objects .filter (
340
+ is_published = True , production_day__day_of_sale__lt = self .day_of_sale
341
+ )
342
+ production_day_next = production_day_next .available_to_user (user )
343
+ production_day_next = production_day_next .order_by (
344
+ "-production_day__day_of_sale"
345
+ ).first ()
346
+ if production_day_next :
347
+ return production_day_next .production_day
348
+ return None
349
+
326
350
327
351
class ProductionDayProductQuerySet (models .QuerySet ):
328
352
def available_to_user (self , user ):
0 commit comments