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
This commit is contained in:
Cédric Krier
2020-07-21 00:36:40 +02:00
parent c879b422a2
commit f5730e2a6a
+3 -1
View File
@@ -11,6 +11,7 @@ from trytond.model import ModelSQL, ModelView, Workflow, fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.tools import sortable_values
from .exceptions import ClosePeriodWarning
@@ -160,7 +161,8 @@ class TaxLine(metaclass=PoolMeta):
if not lines:
return
to_save = []
lines = cls.browse(sorted(lines, key=cls.group_cash_basis_key))
lines = cls.browse(sorted(
lines, key=sortable_values(cls.group_cash_basis_key)))
for key, lines in groupby(lines, key=cls.group_cash_basis_key):
key = dict(key)
if not key['on_cash_basis']: