mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
Validate warehouse for allowed users and matched company
This commit is contained in:
@@ -22,13 +22,14 @@ class DocType:
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"In Process", "Completed", "Cancelled"])
|
||||
|
||||
if self.doc.production_item :
|
||||
item_detail = sql("select name from `tabItem` where name = '%s' and docstatus != 2"
|
||||
% self.doc.production_item, as_dict = 1)
|
||||
if not item_detail:
|
||||
msgprint("Item '%s' does not exist or cancelled in the system."
|
||||
% cstr(self.doc.production_item), raise_exception=1)
|
||||
|
||||
self.validate_bom_no()
|
||||
self.validate_sales_order()
|
||||
self.validate_warehouse()
|
||||
|
||||
from utilities.transaction_base import validate_uom_is_integer
|
||||
validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
|
||||
|
||||
def validate_bom_no(self):
|
||||
if self.doc.bom_no:
|
||||
bom = sql("""select name from `tabBOM` where name=%s and docstatus=1
|
||||
and is_active=1 and item=%s"""
|
||||
@@ -38,16 +39,20 @@ class DocType:
|
||||
May be BOM not exists or inactive or not submitted
|
||||
or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1)
|
||||
|
||||
def validate_sales_order(self):
|
||||
if self.doc.sales_order:
|
||||
if not webnotes.conn.sql("""select name from `tabSales Order`
|
||||
where name=%s and docstatus = 1""", self.doc.sales_order):
|
||||
msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
|
||||
|
||||
|
||||
self.validate_production_order_against_so()
|
||||
|
||||
from utilities.transaction_base import validate_uom_is_integer
|
||||
validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
|
||||
|
||||
|
||||
def validate_warehouse(self):
|
||||
from stock.utils import validate_warehouse_user, validate_warehouse_company
|
||||
|
||||
for w in [self.doc.fg_warehouse, self.doc.wip_warehouse]:
|
||||
validate_warehouse_user(w)
|
||||
validate_warehouse_company(w, self.doc.company)
|
||||
|
||||
def validate_production_order_against_so(self):
|
||||
# already ordered qty
|
||||
|
||||
Reference in New Issue
Block a user