mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 05:09:11 +00:00
[minor] add abbr if missing
This commit is contained in:
@@ -32,6 +32,9 @@ class Company(Document):
|
|||||||
self.validate_currency()
|
self.validate_currency()
|
||||||
|
|
||||||
def validate_abbr(self):
|
def validate_abbr(self):
|
||||||
|
if not self.abbr:
|
||||||
|
self.abbr = ''.join([c[0] for c in self.company_name.split()]).upper()
|
||||||
|
|
||||||
self.abbr = self.abbr.strip()
|
self.abbr = self.abbr.strip()
|
||||||
|
|
||||||
if self.get('__islocal') and len(self.abbr) > 5:
|
if self.get('__islocal') and len(self.abbr) > 5:
|
||||||
@@ -66,7 +69,7 @@ class Company(Document):
|
|||||||
if not frappe.local.flags.ignore_chart_of_accounts:
|
if not frappe.local.flags.ignore_chart_of_accounts:
|
||||||
self.create_default_accounts()
|
self.create_default_accounts()
|
||||||
self.create_default_warehouses()
|
self.create_default_warehouses()
|
||||||
|
|
||||||
self.install_country_fixtures()
|
self.install_country_fixtures()
|
||||||
|
|
||||||
if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
|
if not frappe.db.get_value("Cost Center", {"is_group": 0, "company": self.name}):
|
||||||
@@ -92,7 +95,7 @@ class Company(Document):
|
|||||||
{"warehouse_name": _("Stores"), "is_group": 0},
|
{"warehouse_name": _("Stores"), "is_group": 0},
|
||||||
{"warehouse_name": _("Work In Progress"), "is_group": 0},
|
{"warehouse_name": _("Work In Progress"), "is_group": 0},
|
||||||
{"warehouse_name": _("Finished Goods"), "is_group": 0}]:
|
{"warehouse_name": _("Finished Goods"), "is_group": 0}]:
|
||||||
|
|
||||||
if not frappe.db.exists("Warehouse", "{0} - {1}".format(wh_detail["warehouse_name"], self.abbr)):
|
if not frappe.db.exists("Warehouse", "{0} - {1}".format(wh_detail["warehouse_name"], self.abbr)):
|
||||||
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
|
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
|
||||||
"is_group": 1, "company": self.name})
|
"is_group": 1, "company": self.name})
|
||||||
@@ -203,9 +206,9 @@ class Company(Document):
|
|||||||
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
|
rec = frappe.db.sql("SELECT name from `tabGL Entry` where company = %s", self.name)
|
||||||
if not rec:
|
if not rec:
|
||||||
frappe.db.sql("""delete from `tabBudget Account`
|
frappe.db.sql("""delete from `tabBudget Account`
|
||||||
where exists(select name from tabBudget
|
where exists(select name from tabBudget
|
||||||
where name=`tabBudget Account`.parent and company = %s)""", self.name)
|
where name=`tabBudget Account`.parent and company = %s)""", self.name)
|
||||||
|
|
||||||
for doctype in ["Account", "Cost Center", "Budget", "Party Account"]:
|
for doctype in ["Account", "Cost Center", "Budget", "Party Account"]:
|
||||||
frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)
|
frappe.db.sql("delete from `tab{0}` where company = %s".format(doctype), self.name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user