From 260d1f70b6e519a18be4bb2c53c695ea940f2dd3 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 6 Jun 2019 19:22:13 +0200 Subject: [PATCH] Catch error when removing non existant products It should not fail when the product has been removed by get_shortage issue8354 review267421002 --- production.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/production.py b/production.py index 4994d49cfb..87dcf374d0 100644 --- a/production.py +++ b/production.py @@ -197,7 +197,11 @@ class Production(metaclass=PoolMeta): while (products_period and products_period[0][0] <= (current_date - date)): _, product = products_period.pop(0) - product_ids.remove(product.id) + try: + product_ids.remove(product.id) + except ValueError: + # product may have been already removed on get_shortages + pass current_date += datetime.timedelta(1) # Update current quantities with next moves