[FIX] pms: sort pricelist whitout start or date end (#29)

Co-authored-by: Brais Abeijón <a17braisab@iessanclemente.net>
This commit is contained in:
braisab
2020-12-22 11:04:07 +01:00
committed by GitHub
parent 5f7bd6b540
commit d82c91c854
2 changed files with 317 additions and 2 deletions

View File

@@ -71,11 +71,16 @@ class ProductPricelist(models.Model):
lambda i: not i.pms_property_ids
or self._context["property"] in i.pms_property_ids.ids
)
reverse_id = items_filtered.sorted(id, reverse=True)
return items_filtered.sorted(
key=lambda s: (
(s.applied_on),
((s.date_end - s.date_start).days),
s.applied_on,
True if (not s.date_end or not s.date_start) else False,
True
if (not s.date_end or not s.date_start)
else (s.date_end - s.date_start).days,
((not s.pms_property_ids, s), len(s.pms_property_ids)),
reverse_id,
)
)
return items