Skip to content

Commit

Permalink
acquisitions: sort lines in order
Browse files Browse the repository at this point in the history
Line sorting is now done on the PID to keep the same order as the command.

* Closes rero#2653.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Sep 20, 2023
1 parent 770dc5e commit fc96041
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rero_ils/modules/acquisition/acq_orders/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,22 @@ def get_order_lines(self, output=None, includes=None):
:param includes: a list of statuses to include order lines.
:return a generator of related order lines (or length).
"""
query = AcqOrderLinesSearch().filter('term', acq_order__pid=self.pid)
query = AcqOrderLinesSearch()\
.filter('term', acq_order__pid=self.pid)
if includes:
query = query.filter('terms', status=includes)

if output == 'count':
return query.count()
elif output == 'query':
return query
return query \
.params(preserve_order=True) \
.sort({'pid': {"order": "asc"}})
else:
return get_objects(AcqOrderLine, query)
return get_objects(AcqOrderLine, query
.params(preserve_order=True)
.sort({'pid': {"order": "asc"}})
)

def get_order_provisional_total_amount(self):
"""Get provisional total amount of this order."""
Expand Down

0 comments on commit fc96041

Please sign in to comment.