From 7be6fa1e9181a0b81bf757c1e5339516e8407b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 13 Sep 2026 14:01:21 +0200 Subject: [PATCH] Returns unique and ordered shipments when extending sale and purchase for kit Since 9385c3660f17 the super method returns instances so only instances must be added to the set to ensure uniqueness. Closes #15091 (grafted from 7b9bcbe10ded642353834ba189a888119d7073ae) --HG-- branch : 8.0 --- modules/product_kit/common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/product_kit/common.py b/modules/product_kit/common.py index a65c01b6c9..1085cfb193 100644 --- a/modules/product_kit/common.py +++ b/modules/product_kit/common.py @@ -4,7 +4,7 @@ from collections import defaultdict from decimal import Decimal from functools import wraps -from trytond.model import ModelStorage, ModelView, Workflow, fields +from trytond.model import ModelStorage, ModelView, Workflow, fields, sort from trytond.pool import Pool from trytond.pyson import Eval @@ -15,13 +15,15 @@ def get_shipments_returns(model_name): def wrapper(self, name): pool = Pool() Model = pool.get(model_name) + field = getattr(self.__class__, name) + order = field.order if field.order is not None else Model._order shipments = set(func(self, name)) for line in self.lines: for component in line.components: for move in component.moves: if isinstance(move.shipment, Model): - shipments.add(move.shipment.id) - return list(shipments) + shipments.add(move.shipment) + return sort(shipments, order) return wrapper return _get_shipments_returns