diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 427d5a104e5..77ee04d3390 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -19,18 +19,18 @@ from erpnext.controllers.sales_and_purchase_return import ( filter_serial_batches, make_serial_batch_bundle_for_return, ) -from erpnext.setup.doctype.brand.brand import get_brand_defaults -from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults -from erpnext.stock import get_warehouse_account_map -from erpnext.stock.doctype.item.item import get_item_defaults -# Re-exported for backward compatibility; canonical home is erpnext.stock.exceptions. -from erpnext.stock.exceptions import ( +# Re-exported for backward compatibility; canonical home is erpnext.exceptions. +from erpnext.exceptions import ( BatchExpiredError, QualityInspectionNotSubmittedError, QualityInspectionRejectedError, QualityInspectionRequiredError, ) +from erpnext.setup.doctype.brand.brand import get_brand_defaults +from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults +from erpnext.stock import get_warehouse_account_map +from erpnext.stock.doctype.item.item import get_item_defaults from erpnext.stock.services.internal_transfer import StockInternalTransferService from erpnext.stock.stock_ledger import get_items_to_be_repost diff --git a/erpnext/exceptions.py b/erpnext/exceptions.py index e12c69757e0..c8d2d790d1b 100644 --- a/erpnext/exceptions.py +++ b/erpnext/exceptions.py @@ -28,3 +28,20 @@ class MandatoryAccountDimensionError(frappe.ValidationError): class ReportingCurrencyExchangeNotFoundError(frappe.ValidationError): pass + + +# stock +class QualityInspectionRequiredError(frappe.ValidationError): + pass + + +class QualityInspectionRejectedError(frappe.ValidationError): + pass + + +class QualityInspectionNotSubmittedError(frappe.ValidationError): + pass + + +class BatchExpiredError(frappe.ValidationError): + pass diff --git a/erpnext/stock/exceptions.py b/erpnext/stock/exceptions.py deleted file mode 100644 index 5ec9c6f1b28..00000000000 --- a/erpnext/stock/exceptions.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -"""Shared exceptions for stock transactions. - -Raised by the stock services (serial/batch bundle, quality inspection) and -re-exported from ``stock_controller`` for backward compatibility, so the services -do not have to import back from the controller they were extracted out of. -""" - -import frappe - - -class QualityInspectionRequiredError(frappe.ValidationError): - pass - - -class QualityInspectionRejectedError(frappe.ValidationError): - pass - - -class QualityInspectionNotSubmittedError(frappe.ValidationError): - pass - - -class BatchExpiredError(frappe.ValidationError): - pass diff --git a/erpnext/stock/services/quality_inspection.py b/erpnext/stock/services/quality_inspection.py index d9441bc6826..7e7fc4ba078 100644 --- a/erpnext/stock/services/quality_inspection.py +++ b/erpnext/stock/services/quality_inspection.py @@ -10,7 +10,7 @@ inspection have a present / submitted / non-rejected Quality Inspection. import frappe from frappe import _ -from erpnext.stock.exceptions import ( +from erpnext.exceptions import ( QualityInspectionNotSubmittedError, QualityInspectionRejectedError, QualityInspectionRequiredError, diff --git a/erpnext/stock/services/serial_batch_bundle.py b/erpnext/stock/services/serial_batch_bundle.py index dce7be2beb3..17b3af32fd7 100644 --- a/erpnext/stock/services/serial_batch_bundle.py +++ b/erpnext/stock/services/serial_batch_bundle.py @@ -102,8 +102,8 @@ class SerialBatchBundleService: ) def validate_serialized_batch(self): + from erpnext.exceptions import BatchExpiredError from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos - from erpnext.stock.exceptions import BatchExpiredError is_material_issue = False if self.doc.doctype == "Stock Entry" and self.doc.purpose in ["Material Issue", "Material Transfer"]: