diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index e4c67af0..23bb27fe 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -737,14 +737,36 @@ class ReceivingBatchView(PurchasingBatchView): return breakdown def allow_edit_catalog_unit_cost(self, batch): - return (not batch.executed - and self.has_perm('edit_row') - and self.batch_handler.allow_receiving_edit_catalog_unit_cost()) + + # batch must not yet be frozen + if batch.executed or batch.complete: + return False + + # user must have edit_row perm + if not self.has_perm('edit_row'): + return False + + # config must allow this generally + if not self.batch_handler.allow_receiving_edit_catalog_unit_cost(): + return False + + return True def allow_edit_invoice_unit_cost(self, batch): - return (not batch.executed - and self.has_perm('edit_row') - and self.batch_handler.allow_receiving_edit_invoice_unit_cost()) + + # batch must not yet be frozen + if batch.executed or batch.complete: + return False + + # user must have edit_row perm + if not self.has_perm('edit_row'): + return False + + # config must allow this generally + if not self.batch_handler.allow_receiving_edit_invoice_unit_cost(): + return False + + return True def template_kwargs_view(self, **kwargs): kwargs = super(ReceivingBatchView, self).template_kwargs_view(**kwargs)