Reviewers: ,


Please review this at http://codereview.tryton.org/533002/

Affected files:
  M purchase.py
  M tests/test_stock_supply_day.py


Index: purchase.py
===================================================================
--- a/purchase.py
+++ b/purchase.py
@@ -23,7 +23,7 @@
             if earlier_date and earlier_date <= new_date:
                 continue
             earlier_date = new_date
-        return earlier_date
+        return earlier_date or date

     def compute_purchase_date(self, product_supplier, date):
         later_date = None
Index: tests/test_stock_supply_day.py
===================================================================
--- a/tests/test_stock_supply_day.py
+++ b/tests/test_stock_supply_day.py
@@ -62,6 +62,8 @@
(datetime.date(2011, 11, 21), 5, 5, datetime.date(2011, 11, 26)), (datetime.date(2011, 11, 21), 4, 6, datetime.date(2011, 11, 27)), (datetime.date(2011, 12, 22), 12, 6, datetime.date(2012, 1, 8)),
+            (datetime.date(2011, 11, 21), 10, None,
+                datetime.date(2011, 12, 1)),
             ]
# Purchase date is Monday, 2011-11-21, the regular days to deliver
             # is 10 days, which would be Wednesday 2011-12-01. But with the
@@ -154,10 +156,11 @@
             'party': supplier_id,
             'delivery_time': delivery_time,
             })
-        self.product_supplier_day.create({
-            'product_supplier': product_supplier_id,
-            'weekday': str(weekday),
-            })
+        if weekday is not None:
+            self.product_supplier_day.create({
+                'product_supplier': product_supplier_id,
+                'weekday': str(weekday),
+                })
         return product_supplier_id




--
[email protected] mailing list

Reply via email to