Sort mobile receiving rows by last modified instead of sequence

because we now prefer to aggregate rows for that, at least by default
This commit is contained in:
Lance Edgar 2018-07-10 09:06:22 -05:00
parent 44663fe548
commit 053fc4eb55

View file

@ -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))