changeset 99d05c59a44c in modules/carrier_weight:default
details: 
https://hg.tryton.org/modules/carrier_weight?cmd=changeset;node=99d05c59a44c
description:
        Ensure values can be sorted

        The values may contain None which is not orderable so we insert a third
        argument before the value to prevent to compare None value against 
others.

        issue9381
        review303881005
diffstat:

 sale.py  |  3 ++-
 stock.py |  5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r ca25f0bff571 -r 99d05c59a44c sale.py
--- a/sale.py   Thu Jul 09 10:21:06 2020 +0100
+++ b/sale.py   Tue Jul 21 00:36:40 2020 +0200
@@ -4,6 +4,7 @@
 from itertools import groupby
 
 from trytond.pool import PoolMeta
+from trytond.tools import sortable_values
 
 from .common import parcel_weight
 
@@ -28,7 +29,7 @@
 
         lines = [l for l in self.lines or [] if l.quantity and l.quantity > 0]
         keyfunc = partial(self._group_parcel_key, lines)
-        lines = sorted(lines, key=keyfunc)
+        lines = sorted(lines, key=sortable_values(keyfunc))
 
         for key, parcel in groupby(lines, key=keyfunc):
             weights.append(parcel_weight(
diff -r ca25f0bff571 -r 99d05c59a44c stock.py
--- a/stock.py  Thu Jul 09 10:21:06 2020 +0100
+++ b/stock.py  Tue Jul 21 00:36:40 2020 +0200
@@ -4,6 +4,7 @@
 from functools import partial
 
 from trytond.pool import PoolMeta
+from trytond.tools import sortable_values
 
 from .common import parcel_weight
 
@@ -29,7 +30,7 @@
 
         lines = self.incoming_moves or []
         keyfunc = partial(self._group_parcel_key, lines)
-        lines = sorted(lines, key=keyfunc)
+        lines = sorted(lines, key=sortable_values(keyfunc))
 
         for key, parcel in groupby(lines, key=keyfunc):
             weights.append(parcel_weight(parcel, self.carrier.weight_uom))
@@ -57,7 +58,7 @@
 
         lines = self.inventory_moves or []
         keyfunc = partial(self._group_parcel_key, lines)
-        lines = sorted(lines, key=keyfunc)
+        lines = sorted(lines, key=sortable_values(keyfunc))
 
         for key, parcel in groupby(lines, key=keyfunc):
             weights.append(parcel_weight(parcel, self.carrier.weight_uom))

Reply via email to