Changeset 006a709 in tailbone


Ignore:
Timestamp:
03/02/19 18:07:07 (7 weeks ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
ef7466e
Parents:
b7a026a
Message:

Add ability to sort by Credits? column for receiving batch rows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/views/purchasing/receiving.py

    rb7a026a r006a709  
    749749        g.set_label('department_name', "Department")
    750750
     751        # credits
     752        # note that sorting by credits involves a subquery with group by clause.
     753        # seems likely there may be a better way? but this seems to work fine
     754        Credits = self.Session.query(model.PurchaseBatchCredit.row_uuid,
     755                                     sa.func.count().label('credit_count'))\
     756                              .group_by(model.PurchaseBatchCredit.row_uuid)\
     757                              .subquery()
     758        g.set_joiner('credits', lambda q: q.outerjoin(Credits))
     759        g.sorters['credits'] = lambda q, d: q.order_by(getattr(Credits.c.credit_count, d)())
     760
    751761        # hide 'ordered' columns for truck dump parent, if its "children first"
    752762        # flag is set, since that batch type is only concerned with receiving
Note: See TracChangeset for help on using the changeset viewer.