fix: Sort lists before calling itertools.groupby

(cherry picked from commit 45a6ecbd38)
This commit is contained in:
Corentin Forler
2024-07-22 10:11:37 +02:00
committed by Mergify
parent f376abf0fe
commit d8939e0bb0
4 changed files with 9 additions and 4 deletions

View File

@@ -1097,7 +1097,8 @@ def create_delivery_note(source_name, target_doc=None):
)
)
for customer, rows in groupby(sales_orders, key=lambda so: so["customer"]):
group_key = lambda so: so["customer"] # noqa
for customer, rows in groupby(sorted(sales_orders, key=group_key), key=group_key):
sales_dict[customer] = {row.sales_order for row in rows}
if sales_dict: