diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index 452a8a75..f1b5d4eb 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -571,15 +571,22 @@ class ReceivingBatchView(PurchasingBatchView): def get_mobile_row_data(self, parent): query = self.get_row_data(parent) - aggregate_products = not bool(parent.truck_dump) # TODO: make this configurable? - if not aggregate_products: - query = query.order_by(model.PurchaseBatchRow.sequence.desc()) - return query + return self.sort_mobile_row_data(query) + + def sort_mobile_row_data(self, query): + return query.order_by(model.PurchaseBatchRow.modified.desc()) def render_mobile_row_listitem(self, row, i): description = row.product.full_description if row.product else row.description return "({}) {}".format(row.upc.pretty(), description) + def should_aggregate_products(self, batch): + """ + Must return a boolean indicating whether rows should be aggregated by + product for the given batch. + """ + return True + # TODO: this view can create new rows, with only a GET query. that should # probably be changed to require POST; for now we just require the "create # batch row" perm and call it good.. @@ -606,8 +613,7 @@ class ReceivingBatchView(PurchasingBatchView): .all() if rows: - aggregate_products = not bool(batch.truck_dump) # TODO: make this configurable? - if aggregate_products: + if self.should_aggregate_products(batch): if len(rows) > 1: log.warning("found multiple UPC matches for {} in batch {}: {}".format( upc, batch.id_str, batch))