added warehouse company validation, if warehouse is added to company
This commit is contained in:
parent
256f29a580
commit
c5570c6341
@ -67,6 +67,11 @@ class DocType(AccountsController):
|
||||
remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv")
|
||||
|
||||
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):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
|
@ -7,4 +7,10 @@ test_records = [
|
||||
"abbr": "_TC",
|
||||
"default_currency": "INR",
|
||||
}],
|
||||
[{
|
||||
"doctype": "Company",
|
||||
"company_name": "_Test Company 1",
|
||||
"abbr": "_TC1",
|
||||
"default_currency": "USD",
|
||||
}],
|
||||
]
|
@ -25,7 +25,14 @@ class TestStockEntry(unittest.TestCase):
|
||||
where item_code='_Test Item'""")
|
||||
|
||||
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):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||
|
@ -24,7 +24,7 @@ sql = webnotes.conn.sql
|
||||
msgprint = webnotes.msgprint
|
||||
from accounts.utils import get_fiscal_year
|
||||
|
||||
|
||||
class InvalidWarehouseCompany(Exception): pass
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
@ -35,6 +35,7 @@ class DocType:
|
||||
self.validate_mandatory()
|
||||
self.validate_item()
|
||||
self.validate_warehouse_user()
|
||||
self.validate_warehouse_company()
|
||||
self.actual_amt_check()
|
||||
self.check_stock_frozen_date()
|
||||
self.scrub_posting_time()
|
||||
@ -63,6 +64,13 @@ class DocType:
|
||||
webnotes.msgprint(_("User not allowed entry in the Warehouse") \
|
||||
+ ": " + 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):
|
||||
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']
|
||||
for k in mandatory:
|
||||
|
@ -7,6 +7,12 @@ test_records = [
|
||||
[{
|
||||
"doctype": "Warehouse",
|
||||
"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"
|
||||
}]
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user