Skip to content

Commit

Permalink
fix: don't allow to submit/cancel SCR against a closed SCO
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Jan 3, 2024
1 parent 5e2669f commit 9e97347
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import erpnext
from erpnext.accounts.utils import get_account_currency
from erpnext.buying.utils import check_on_hold_or_closed_status
from erpnext.controllers.subcontracting_controller import SubcontractingController
from erpnext.stock.stock_ledger import get_valuation_rate

Expand Down Expand Up @@ -142,6 +143,7 @@ def validate(self):
self.get_current_stock()

def on_submit(self):
self.validate_closed_subcontracting_order()
self.validate_available_qty_for_consumption()
self.update_status_updater_args()
self.update_prevdoc_status()
Expand All @@ -165,6 +167,7 @@ def on_cancel(self):
"Repost Item Valuation",
"Serial and Batch Bundle",
)
self.validate_closed_subcontracting_order()
self.update_status_updater_args()
self.update_prevdoc_status()
self.set_consumed_qty_in_subcontract_order()
Expand All @@ -175,6 +178,11 @@ def on_cancel(self):
self.update_status()
self.delete_auto_created_batches()

def validate_closed_subcontracting_order(self):
for item in self.items:
if item.subcontracting_order:
check_on_hold_or_closed_status("Subcontracting Order", item.subcontracting_order)

def validate_items_qty(self):
for item in self.items:
if not (item.qty or item.rejected_qty):
Expand Down

0 comments on commit 9e97347

Please sign in to comment.