Merge pull request #24546 from pateljannat/validation-for-disabled-warehouse-v12

Validation for disabled warehouse v12
This commit is contained in:
Marica
2021-02-11 13:09:29 +05:30
committed by GitHub
3 changed files with 9 additions and 3 deletions

View File

@@ -319,12 +319,13 @@ class StockController(AccountsController):
return incoming_rate
def validate_warehouse(self):
from erpnext.stock.utils import validate_warehouse_company
from erpnext.stock.utils import validate_warehouse_company, validate_disabled_warehouse
warehouses = list(set([d.warehouse for d in
self.get("items") if getattr(d, "warehouse", None)]))
for w in warehouses:
validate_disabled_warehouse(w)
validate_warehouse_company(w, self.company)
def update_billing_percentage(self, update_modified=True):

View File

@@ -25,10 +25,11 @@ class StockLedgerEntry(Document):
def validate(self):
self.flags.ignore_submit_comment = True
from erpnext.stock.utils import validate_warehouse_company
from erpnext.stock.utils import validate_warehouse_company, validate_disabled_warehouse
self.validate_mandatory()
self.validate_item()
self.validate_batch()
validate_disabled_warehouse(self.warehouse)
validate_warehouse_company(self.warehouse, self.company)
self.scrub_posting_time()
self.validate_and_set_fiscal_year()

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe, erpnext
from frappe import _
import json
from frappe.utils import flt, cstr, nowdate, nowtime
from frappe.utils import flt, cstr, nowdate, nowtime, get_link_to_form
from six import string_types
@@ -279,6 +279,10 @@ def is_group_warehouse(warehouse):
if frappe.db.get_value("Warehouse", warehouse, "is_group"):
frappe.throw(_("Group node warehouse is not allowed to select for transactions"))
def validate_disabled_warehouse(warehouse):
if frappe.db.get_value("Warehouse", warehouse, "disabled"):
frappe.throw(_("Disabled Warehouse {0} cannot be used for this transaction.").format(get_link_to_form('Warehouse', warehouse)))
def update_included_uom_in_report(columns, result, include_uom, conversion_factors):
if not include_uom or not conversion_factors:
return