mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-20 09:49:58 +00:00
refactor(stock): drop 7 in-repo-only StockController delegators
Remove the delegators whose only callers were in-repo StockController subclasses, repointing every caller to the owning service / free function: - validate_warehouse_of_sabb, validate_duplicate_serial_and_batch_bundle, validate_serialized_batch, clean_serial_nos -> SerialBatchBundleService - update_inventory_dimensions -> StockLedgerService - validate_putaway_capacity -> putaway_rule.validate_putaway_capacity (free fn) - set_landed_cost_voucher_amount -> landed_cost_voucher.set_landed_cost_voucher_amount Callers repointed: StockController.validate() (base), StockEntry.validate(), StockReconciliation (validate + reconciliation SLE build), BuyingController.validate(), and the Landed Cost Voucher submit (doc.set_landed_cost_voucher_amount on the receipt). Verified green: ledger snapshots, stock_entry (91), stock_reconciliation (34), landed_cost_voucher (15), subcontracting_receipt (32), delivery_note (71).
This commit is contained in:
@@ -37,33 +37,33 @@ from erpnext.stock.stock_ledger import get_items_to_be_repost
|
||||
|
||||
class StockController(AccountsController):
|
||||
def validate(self):
|
||||
from erpnext.stock.doctype.putaway_rule.putaway_rule import validate_putaway_capacity
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
sbb = SerialBatchBundleService(self)
|
||||
|
||||
super().validate()
|
||||
|
||||
if self.docstatus == 0:
|
||||
for table_name in ["items", "packed_items", "supplied_items"]:
|
||||
self.validate_duplicate_serial_and_batch_bundle(table_name)
|
||||
sbb.validate_duplicate_serial_and_batch_bundle(table_name)
|
||||
|
||||
if not self.get("is_return"):
|
||||
self.validate_inspection()
|
||||
|
||||
self.validate_warehouse_of_sabb()
|
||||
self.validate_serialized_batch()
|
||||
self.clean_serial_nos()
|
||||
sbb.validate_warehouse_of_sabb()
|
||||
sbb.validate_serialized_batch()
|
||||
sbb.clean_serial_nos()
|
||||
self.validate_customer_provided_item()
|
||||
self.set_rate_of_stock_uom()
|
||||
StockInternalTransferService(self).validate_internal_transfer()
|
||||
self.validate_putaway_capacity()
|
||||
validate_putaway_capacity(self)
|
||||
self.reset_conversion_factor()
|
||||
|
||||
def on_update(self):
|
||||
super().on_update()
|
||||
self.check_zero_rate()
|
||||
|
||||
def validate_warehouse_of_sabb(self):
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
return SerialBatchBundleService(self).validate_warehouse_of_sabb()
|
||||
|
||||
def reset_conversion_factor(self):
|
||||
for row in self.get("items"):
|
||||
if row.uom != row.stock_uom:
|
||||
@@ -118,11 +118,6 @@ class StockController(AccountsController):
|
||||
if non_exists_items:
|
||||
frappe.throw(_("Items {0} do not exist in the Item master.").format(", ".join(non_exists_items)))
|
||||
|
||||
def validate_duplicate_serial_and_batch_bundle(self, table_name):
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
return SerialBatchBundleService(self).validate_duplicate_serial_and_batch_bundle(table_name)
|
||||
|
||||
def get_item_wise_inventory_account_map(self):
|
||||
inventory_account_map = frappe._dict()
|
||||
for table in ["items", "packed_items", "supplied_items"]:
|
||||
@@ -207,16 +202,6 @@ class StockController(AccountsController):
|
||||
)
|
||||
make_gl_entries(gl_entries, from_repost=from_repost)
|
||||
|
||||
def validate_serialized_batch(self):
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
return SerialBatchBundleService(self).validate_serialized_batch()
|
||||
|
||||
def clean_serial_nos(self):
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
return SerialBatchBundleService(self).clean_serial_nos()
|
||||
|
||||
def make_bundle_using_old_serial_batch_fields(self, table_name=None, via_landed_cost_voucher=False):
|
||||
from erpnext.stock.services.serial_batch_bundle import SerialBatchBundleService
|
||||
|
||||
@@ -277,13 +262,6 @@ class StockController(AccountsController):
|
||||
|
||||
return StockLedgerService(self).get_sl_entries(d, args)
|
||||
|
||||
def set_landed_cost_voucher_amount(self):
|
||||
from erpnext.stock.doctype.landed_cost_voucher.landed_cost_voucher import (
|
||||
set_landed_cost_voucher_amount,
|
||||
)
|
||||
|
||||
return set_landed_cost_voucher_amount(self)
|
||||
|
||||
def get_item_account_wise_lcv_entries(self):
|
||||
from erpnext.stock.doctype.landed_cost_voucher.landed_cost_voucher import (
|
||||
get_item_account_wise_lcv_entries,
|
||||
@@ -291,11 +269,6 @@ class StockController(AccountsController):
|
||||
|
||||
return get_item_account_wise_lcv_entries(self)
|
||||
|
||||
def update_inventory_dimensions(self, row, sl_dict) -> None:
|
||||
from erpnext.stock.services.stock_ledger import StockLedgerService
|
||||
|
||||
return StockLedgerService(self).update_inventory_dimensions(row, sl_dict)
|
||||
|
||||
def make_sl_entries(self, sl_entries, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||
from erpnext.stock.services.stock_ledger import StockLedgerService
|
||||
|
||||
@@ -386,11 +359,6 @@ class StockController(AccountsController):
|
||||
for d in self.get("items"):
|
||||
d.stock_uom_rate = d.rate / (d.conversion_factor or 1)
|
||||
|
||||
def validate_putaway_capacity(self):
|
||||
from erpnext.stock.doctype.putaway_rule.putaway_rule import validate_putaway_capacity
|
||||
|
||||
return validate_putaway_capacity(self)
|
||||
|
||||
def repost_future_sle_and_gle(self, force=False, via_landed_cost_voucher=False):
|
||||
from erpnext.stock.services.stock_ledger import StockLedgerService
|
||||
|
||||
|
||||
Reference in New Issue
Block a user