stock_cycle_count: fix issue with nan while doing the mean calculation

This commit is contained in:
Jordi Ballester Alomar
2018-10-17 17:58:42 +02:00
committed by Lois Rilo
parent 539ae5be22
commit 0b83fa9440

View File

@@ -27,7 +27,8 @@ class StockLocation(models.Model):
history = history.sorted(key=lambda r: r.write_date, reverse=True)
if history:
wh = rec.get_warehouse()
if len(history) > wh.counts_for_accuracy_qty:
if wh.counts_for_accuracy_qty and \
len(history) > wh.counts_for_accuracy_qty:
rec.loc_accuracy = mean(
history[:wh.counts_for_accuracy_qty].mapped(
'inventory_accuracy'))