Don't allow deletion of some receiving data rows on mobile

specifically, rows on a truck dump parent, which originated from a child
batch (and therefore presumably, an invoice)
This commit is contained in:
Lance Edgar 2019-03-27 20:11:32 -05:00
parent 9ace36c459
commit d60679adfd

View file

@ -279,8 +279,28 @@ class ReceivingBatchView(PurchasingBatchView):
def row_deletable(self, row): def row_deletable(self, row):
batch = row.batch batch = row.batch
# can always delete rows from truck dump parent # don't allow if master view has disabled that entirely
if not self.rows_deletable:
return False
# can never delete rows for complete/executed batches
# TODO: not so sure about the 'complete' part though..?
if batch.executed or batch.complete:
return False
# can "always" delete rows from truck dump parent...
if batch.is_truck_dump_parent(): if batch.is_truck_dump_parent():
# ...but only on desktop!
if not self.mobile:
return True
# ...for mobile we only allow deletion of rows which did *not* come
# from a child batch, i.e. can delete ad-hoc rows only
# TODO: should have a better way to detect this; for now we rely on
# the fact that only rows from an invoice or similar would have
# order quantities
if not (row.cases_ordered or row.units_ordered):
return True return True
# can always delete rows from truck dump child # can always delete rows from truck dump child