mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 05:29:18 +00:00
Validate warehouse for allowed users and matched company
This commit is contained in:
@@ -68,22 +68,14 @@ class DocType(BuyingController):
|
||||
self.doc.status = "Draft"
|
||||
|
||||
import utilities
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
|
||||
"Cancelled"])
|
||||
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", "Cancelled"])
|
||||
|
||||
# restrict material request type
|
||||
self.validate_value("material_request_type", "in", ["Purchase", "Transfer"])
|
||||
|
||||
# Get Purchase Common Obj
|
||||
pc_obj = get_obj(dt='Purchase Common')
|
||||
|
||||
|
||||
# Validate for items
|
||||
pc_obj.validate_for_items(self)
|
||||
|
||||
# Validate qty against SO
|
||||
self.validate_qty_against_so()
|
||||
|
||||
self.validate_qty_against_so()
|
||||
|
||||
def update_bin(self, is_submit, is_stopped):
|
||||
""" Update Quantity Requested for Purchase in Bin for Material Request of type 'Purchase'"""
|
||||
|
||||
@@ -7,7 +7,6 @@ from webnotes import _, msgprint, ValidationError
|
||||
from webnotes.utils import cint, flt, getdate, cstr
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class InvalidWarehouseCompany(ValidationError): pass
|
||||
class SerialNoNotRequiredError(ValidationError): pass
|
||||
class SerialNoRequiredError(ValidationError): pass
|
||||
class SerialNoQtyError(ValidationError): pass
|
||||
@@ -25,7 +24,7 @@ class DocType(DocListController):
|
||||
self.doclist = doclist
|
||||
|
||||
def validate(self):
|
||||
from stock.utils import validate_warehouse_user
|
||||
from stock.utils import validate_warehouse_user, validate_warehouse_company
|
||||
if not hasattr(webnotes, "new_stock_ledger_entries"):
|
||||
webnotes.new_stock_ledger_entries = []
|
||||
|
||||
@@ -33,7 +32,7 @@ class DocType(DocListController):
|
||||
self.validate_mandatory()
|
||||
self.validate_item()
|
||||
validate_warehouse_user(self.doc.warehouse)
|
||||
self.validate_warehouse_company()
|
||||
validate_warehouse_company(self.doc.warehouse, self.doc.company)
|
||||
self.scrub_posting_time()
|
||||
|
||||
from accounts.utils import validate_fiscal_year
|
||||
@@ -63,13 +62,6 @@ class DocType(DocListController):
|
||||
as on %(posting_date)s %(posting_time)s""" % self.doc.fields)
|
||||
|
||||
sself.doc.fields.pop('batch_bal')
|
||||
|
||||
def validate_warehouse_company(self):
|
||||
warehouse_company = webnotes.conn.get_value("Warehouse", self.doc.warehouse, "company")
|
||||
if warehouse_company and warehouse_company != self.doc.company:
|
||||
webnotes.msgprint(_("Warehouse does not belong to company.") + " (" + \
|
||||
self.doc.warehouse + ", " + self.doc.company +")",
|
||||
raise_exception=InvalidWarehouseCompany)
|
||||
|
||||
def validate_mandatory(self):
|
||||
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']
|
||||
|
||||
@@ -9,6 +9,7 @@ from webnotes.defaults import get_global_default
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
|
||||
class UserNotAllowedForWarehouse(webnotes.ValidationError): pass
|
||||
class InvalidWarehouseCompany(webnotes.ValidationError): pass
|
||||
|
||||
def get_stock_balance_on(warehouse, posting_date=None):
|
||||
if not posting_date: posting_date = nowdate()
|
||||
@@ -216,6 +217,12 @@ def validate_warehouse_user(warehouse):
|
||||
if warehouse_users and not (webnotes.session.user in warehouse_users):
|
||||
webnotes.throw(_("Not allowed entry in Warehouse") \
|
||||
+ ": " + warehouse, UserNotAllowedForWarehouse)
|
||||
|
||||
def validate_warehouse_company(warehouse, company):
|
||||
warehouse_company = webnotes.conn.get_value("Warehouse", warehouse, "company")
|
||||
if warehouse_company and warehouse_company != company:
|
||||
webnotes.msgprint(_("Warehouse does not belong to company.") + " (" + \
|
||||
warehouse + ", " + company +")", raise_exception=InvalidWarehouseCompany)
|
||||
|
||||
def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries, item_sales_bom):
|
||||
|
||||
Reference in New Issue
Block a user