[fix] [minor] validate parent account for warehouse account
This commit is contained in:
parent
ee60763b45
commit
7496b528a1
@ -23,8 +23,6 @@ class DocType:
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
if self.doc.email_id and not validate_email_add(self.doc.email_id):
|
if self.doc.email_id and not validate_email_add(self.doc.email_id):
|
||||||
msgprint("Please enter valid Email Id", raise_exception=1)
|
msgprint("Please enter valid Email Id", raise_exception=1)
|
||||||
|
|
||||||
self.validate_parent_account()
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.create_account_head()
|
self.create_account_head()
|
||||||
@ -36,6 +34,7 @@ class DocType:
|
|||||||
{"account_name": self.doc.warehouse_name}):
|
{"account_name": self.doc.warehouse_name}):
|
||||||
if self.doc.__islocal or not webnotes.conn.get_value("Stock Ledger Entry",
|
if self.doc.__islocal or not webnotes.conn.get_value("Stock Ledger Entry",
|
||||||
{"warehouse": self.doc.name}):
|
{"warehouse": self.doc.name}):
|
||||||
|
self.validate_parent_account()
|
||||||
ac_bean = webnotes.bean({
|
ac_bean = webnotes.bean({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
'account_name': self.doc.warehouse_name,
|
'account_name': self.doc.warehouse_name,
|
||||||
@ -52,15 +51,14 @@ class DocType:
|
|||||||
msgprint(_("Account Head") + ": " + ac_bean.doc.name + _(" created"))
|
msgprint(_("Account Head") + ": " + ac_bean.doc.name + _(" created"))
|
||||||
|
|
||||||
def validate_parent_account(self):
|
def validate_parent_account(self):
|
||||||
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) and \
|
if not self.doc.create_account_under:
|
||||||
not self.doc.create_account_under:
|
parent_account = webnotes.conn.get_value("Account",
|
||||||
parent_account = webnotes.conn.get_value("Account",
|
{"account_name": "Stock Assets", "company": self.doc.company})
|
||||||
{"account_name": "Stock Assets", "company": self.doc.company})
|
if parent_account:
|
||||||
if parent_account:
|
self.doc.create_account_under = parent_account
|
||||||
self.doc.create_account_under = parent_account
|
else:
|
||||||
else:
|
webnotes.throw(_("Please enter account group under which account \
|
||||||
webnotes.throw(_("Please enter account group under which account \
|
for warehouse ") + self.doc.name +_(" will be created"))
|
||||||
for warehouse ") + self.doc.name +_(" will be created"))
|
|
||||||
|
|
||||||
def on_rename(self, new, old):
|
def on_rename(self, new, old):
|
||||||
webnotes.conn.set_value("Account", {"account_type": "Warehouse", "master_name": old},
|
webnotes.conn.set_value("Account", {"account_type": "Warehouse", "master_name": old},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user