mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
added warehouse company validation, if warehouse is added to company
This commit is contained in:
@@ -68,6 +68,11 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
self.make_gl_entries(cancel=1)
|
self.make_gl_entries(cancel=1)
|
||||||
|
|
||||||
|
def on_trash(self):
|
||||||
|
pass
|
||||||
|
#if self.doc.amended_from:
|
||||||
|
# webnotes.delete_doc("Journal Voucher", self.doc.amended_from)
|
||||||
|
|
||||||
def validate_debit_credit(self):
|
def validate_debit_credit(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
if d.debit and d.credit:
|
if d.debit and d.credit:
|
||||||
|
|||||||
@@ -7,4 +7,10 @@ test_records = [
|
|||||||
"abbr": "_TC",
|
"abbr": "_TC",
|
||||||
"default_currency": "INR",
|
"default_currency": "INR",
|
||||||
}],
|
}],
|
||||||
|
[{
|
||||||
|
"doctype": "Company",
|
||||||
|
"company_name": "_Test Company 1",
|
||||||
|
"abbr": "_TC1",
|
||||||
|
"default_currency": "USD",
|
||||||
|
}],
|
||||||
]
|
]
|
||||||
@@ -26,6 +26,13 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(mr_name)
|
self.assertTrue(mr_name)
|
||||||
|
|
||||||
|
def test_warehouse_company_validation(self):
|
||||||
|
from stock.doctype.stock_ledger_entry.stock_ledger_entry import InvalidWarehouseCompany
|
||||||
|
st1 = webnotes.bean(copy=test_records[0])
|
||||||
|
st1.doclist[1].t_warehouse="_Test Warehouse 2"
|
||||||
|
st1.insert()
|
||||||
|
self.assertRaises(InvalidWarehouseCompany, st1.submit)
|
||||||
|
|
||||||
def test_material_receipt_gl_entry(self):
|
def test_material_receipt_gl_entry(self):
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ sql = webnotes.conn.sql
|
|||||||
msgprint = webnotes.msgprint
|
msgprint = webnotes.msgprint
|
||||||
from accounts.utils import get_fiscal_year
|
from accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
|
class InvalidWarehouseCompany(Exception): pass
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=[]):
|
||||||
@@ -35,6 +35,7 @@ class DocType:
|
|||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_item()
|
self.validate_item()
|
||||||
self.validate_warehouse_user()
|
self.validate_warehouse_user()
|
||||||
|
self.validate_warehouse_company()
|
||||||
self.actual_amt_check()
|
self.actual_amt_check()
|
||||||
self.check_stock_frozen_date()
|
self.check_stock_frozen_date()
|
||||||
self.scrub_posting_time()
|
self.scrub_posting_time()
|
||||||
@@ -63,6 +64,13 @@ class DocType:
|
|||||||
webnotes.msgprint(_("User not allowed entry in the Warehouse") \
|
webnotes.msgprint(_("User not allowed entry in the Warehouse") \
|
||||||
+ ": " + webnotes.session.user + " / " + self.doc.warehouse, raise_exception = 1)
|
+ ": " + webnotes.session.user + " / " + self.doc.warehouse, raise_exception = 1)
|
||||||
|
|
||||||
|
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):
|
def validate_mandatory(self):
|
||||||
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']
|
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']
|
||||||
for k in mandatory:
|
for k in mandatory:
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ test_records = [
|
|||||||
[{
|
[{
|
||||||
"doctype": "Warehouse",
|
"doctype": "Warehouse",
|
||||||
"warehouse_name": "_Test Warehouse 1",
|
"warehouse_name": "_Test Warehouse 1",
|
||||||
"warehouse_type": "_Test Warehouse Type"
|
"warehouse_type": "_Test Warehouse Type",
|
||||||
|
}],
|
||||||
|
[{
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "_Test Warehouse 2",
|
||||||
|
"warehouse_type": "_Test Warehouse Type",
|
||||||
|
"company": "_Test Company 1"
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user