From 6274e33a8c8f47958a05d251dd3554e3c4e40b6b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 19 Sep 2023 14:41:15 -0500 Subject: [PATCH] Prevent catalog/invoice cost edits if receiving batch is complete --- tailbone/views/purchasing/receiving.py | 34 +++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) 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)