From a3d9a05f5539d21b29f80c273d7c7d4047b7a747 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Wed, 17 Oct 2018 17:58:42 +0200 Subject: [PATCH] stock_cycle_count: fix issue with nan while doing the mean calculation --- stock_cycle_count/models/stock_location.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stock_cycle_count/models/stock_location.py b/stock_cycle_count/models/stock_location.py index 59750a9f0..030ea0986 100644 --- a/stock_cycle_count/models/stock_location.py +++ b/stock_cycle_count/models/stock_location.py @@ -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'))