From ba09b8989ebbe10aa336dbf850d075fbcda558d0 Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Tue, 9 Oct 2018 17:18:09 +0200 Subject: [PATCH] [FIX] stock_account: group on empty field 65;5401;1c Line contains the value returned by a select clause on inventory lines. postgresql result returns None instead of False when no value is set. Avoid having a stock_histories_by_group dict with a key to None Having a None value is problematic as the key is used based on the read_group result returned by the super call above. e.g. grouping the inventory history by lot numbers, while some moves have no inventory, used to produce a KeyError Closes #27591 --- addons/stock_account/report/stock_history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/report/stock_history.py b/addons/stock_account/report/stock_history.py index 077aea8cef5..fabf4ff7add 100644 --- a/addons/stock_account/report/stock_history.py +++ b/addons/stock_account/report/stock_history.py @@ -53,7 +53,7 @@ class StockHistory(models.Model): stock_histories_by_group = {} for line in self._cr.dictfetchall(): stock_history_data[line['id']] = line - key = tuple(line[g] if g in line else False for g in groupby_list) + key = tuple(line.get(g) or False for g in groupby_list) stock_histories_by_group.setdefault(key, []) stock_histories_by_group[key] += [line['id']]