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
This commit is contained in:
Cédric Krier
2026-09-13 14:01:21 +02:00
parent 55284034da
commit 7be6fa1e91
+5 -3
View File
@@ -4,7 +4,7 @@ from collections import defaultdict
from decimal import Decimal from decimal import Decimal
from functools import wraps 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.pool import Pool
from trytond.pyson import Eval from trytond.pyson import Eval
@@ -15,13 +15,15 @@ def get_shipments_returns(model_name):
def wrapper(self, name): def wrapper(self, name):
pool = Pool() pool = Pool()
Model = pool.get(model_name) 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)) shipments = set(func(self, name))
for line in self.lines: for line in self.lines:
for component in line.components: for component in line.components:
for move in component.moves: for move in component.moves:
if isinstance(move.shipment, Model): if isinstance(move.shipment, Model):
shipments.add(move.shipment.id) shipments.add(move.shipment)
return list(shipments) return sort(shipments, order)
return wrapper return wrapper
return _get_shipments_returns return _get_shipments_returns