Add ability to sort by Credits? column for receiving batch rows
This commit is contained in:
parent
b7a026a7e8
commit
006a7096ed
|
@ -748,6 +748,16 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
super(ReceivingBatchView, self).configure_row_grid(g)
|
||||
g.set_label('department_name', "Department")
|
||||
|
||||
# credits
|
||||
# note that sorting by credits involves a subquery with group by clause.
|
||||
# seems likely there may be a better way? but this seems to work fine
|
||||
Credits = self.Session.query(model.PurchaseBatchCredit.row_uuid,
|
||||
sa.func.count().label('credit_count'))\
|
||||
.group_by(model.PurchaseBatchCredit.row_uuid)\
|
||||
.subquery()
|
||||
g.set_joiner('credits', lambda q: q.outerjoin(Credits))
|
||||
g.sorters['credits'] = lambda q, d: q.order_by(getattr(Credits.c.credit_count, d)())
|
||||
|
||||
# hide 'ordered' columns for truck dump parent, if its "children first"
|
||||
# flag is set, since that batch type is only concerned with receiving
|
||||
batch = self.get_instance()
|
||||
|
|
Loading…
Reference in a new issue