[cleanup] Default Warehouses created on Company creation. Warehouse names have Company abbreviation as suffix
This commit is contained in:
parent
982ad35fd2
commit
ad71473f35
@ -52,6 +52,22 @@ wn.module_page["Accounts"] = [
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Setup"),
|
||||
icon: "icon-wrench",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Company"),
|
||||
description: wn._("Company Master."),
|
||||
doctype:"Company"
|
||||
},
|
||||
{
|
||||
label: wn._("Fiscal Year"),
|
||||
description: wn._("Accounting Year."),
|
||||
doctype:"Fiscal Year"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: wn._("Tools"),
|
||||
icon: "icon-wrench",
|
||||
|
@ -33,9 +33,28 @@ class DocType:
|
||||
if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5:
|
||||
webnotes.msgprint("Abbreviation cannot have more than 5 characters",
|
||||
raise_exception=1)
|
||||
|
||||
# Create default accounts
|
||||
# ---------------------------------------------------
|
||||
|
||||
def on_update(self):
|
||||
if not webnotes.conn.sql("""select name from tabAccount
|
||||
where company=%s and docstatus<2 limit 1""", self.doc.name):
|
||||
self.create_default_accounts()
|
||||
self.create_default_warehouses()
|
||||
|
||||
if not self.doc.cost_center:
|
||||
self.create_default_cost_center()
|
||||
|
||||
self.set_default_accounts()
|
||||
|
||||
if self.doc.default_currency:
|
||||
webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
|
||||
|
||||
def create_default_warehouses(self):
|
||||
for whname in ("Stores", "Work In Progress", "Finished Goods"):
|
||||
webnotes.bean({
|
||||
"doctype":"Warehouse",
|
||||
"company": self.doc.name
|
||||
}).insert()
|
||||
|
||||
def create_default_accounts(self):
|
||||
self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7}
|
||||
acc_list_common = [
|
||||
@ -162,32 +181,16 @@ class DocType:
|
||||
for d in acc_list_india:
|
||||
self.add_acc(d)
|
||||
|
||||
# Create account
|
||||
# ---------------------------------------------------
|
||||
def add_acc(self,lst):
|
||||
ac = Document('Account')
|
||||
account = webnotes.bean({
|
||||
"doctype": "Account",
|
||||
"freeze_account": "No",
|
||||
"master_type": "",
|
||||
})
|
||||
for d in self.fld_dict.keys():
|
||||
ac.fields[d] = (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.doc.abbr or lst[self.fld_dict[d]]
|
||||
ac_obj = get_obj(doc=ac)
|
||||
ac_obj.doc.freeze_account='No'
|
||||
ac_obj.doc.master_type = ''
|
||||
ac_obj.validate()
|
||||
ac_obj.doc.save(1)
|
||||
ac_obj.on_update()
|
||||
|
||||
|
||||
# Set letter head
|
||||
# ---------------------------------------------------
|
||||
def set_letter_head(self):
|
||||
if not self.doc.letter_head:
|
||||
if self.doc.address:
|
||||
header = """
|
||||
<div><h3> %(comp)s </h3> %(add)s </div>
|
||||
|
||||
""" % {'comp':self.doc.name,
|
||||
'add':self.doc.address.replace("\n",'<br>')}
|
||||
|
||||
self.doc.letter_head = header
|
||||
account.doc.fields[d] = (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.doc.abbr or lst[self.fld_dict[d]]
|
||||
|
||||
account.insert()
|
||||
|
||||
def set_default_accounts(self):
|
||||
accounts = {
|
||||
@ -209,8 +212,6 @@ class DocType:
|
||||
if not self.doc.stock_adjustment_cost_center:
|
||||
webnotes.conn.set(self.doc, "stock_adjustment_cost_center", self.doc.cost_center)
|
||||
|
||||
# Create default cost center
|
||||
# ---------------------------------------------------
|
||||
def create_default_cost_center(self):
|
||||
cc_list = [
|
||||
{
|
||||
@ -237,21 +238,6 @@ class DocType:
|
||||
cc_bean.insert()
|
||||
|
||||
webnotes.conn.set(self.doc, "cost_center", "Main - " + self.doc.abbr)
|
||||
|
||||
def on_update(self):
|
||||
self.set_letter_head()
|
||||
|
||||
if not webnotes.conn.sql("""select name from tabAccount
|
||||
where company=%s and docstatus<2 limit 1""", self.doc.name):
|
||||
self.create_default_accounts()
|
||||
|
||||
if not self.doc.cost_center:
|
||||
self.create_default_cost_center()
|
||||
|
||||
self.set_default_accounts()
|
||||
|
||||
if self.doc.default_currency:
|
||||
webnotes.conn.set_value("Currency", self.doc.default_currency, "enabled", 1)
|
||||
|
||||
def on_trash(self):
|
||||
"""
|
||||
|
@ -100,8 +100,10 @@ def import_country_and_currency():
|
||||
def import_defaults():
|
||||
records = [
|
||||
# item group
|
||||
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'name': 'All Item Groups', 'parent_item_group': ''},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'Default', 'is_group': 'No', 'name': 'Default', 'parent_item_group': 'All Item Groups'},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'All Item Groups', 'is_group': 'Yes', 'parent_item_group': ''},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'Products', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'Raw Material', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||
{'doctype': 'Item Group', 'item_group_name': 'Services', 'is_group': 'No', 'parent_item_group': 'All Item Groups'},
|
||||
|
||||
# deduction type
|
||||
{'doctype': 'Deduction Type', 'name': 'Income Tax', 'description': 'Income Tax', 'deduction_name': 'Income Tax'},
|
||||
@ -131,16 +133,25 @@ def import_defaults():
|
||||
|
||||
# customer group
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'All Customer Groups', 'is_group': 'Yes', 'name': 'All Customer Groups', 'parent_customer_group': ''},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Default', 'is_group': 'No', 'name': 'Default Customer Group', 'parent_customer_group': 'All Customer Groups'},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Individual', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Commercial', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Non Profit', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||
{'doctype': 'Customer Group', 'customer_group_name': 'Government', 'is_group': 'No', 'parent_customer_group': 'All Customer Groups'},
|
||||
|
||||
# supplier type
|
||||
{'doctype': 'Supplier Type', 'name': 'Default Supplier Type', 'supplier_type': 'Default Supplier Type'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Services'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Local'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Raw Material'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Electrical'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Hardware'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'},
|
||||
{'doctype': 'Supplier Type', 'supplier_type': 'Distributor'},
|
||||
|
||||
# Workstation
|
||||
{'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'},
|
||||
|
||||
# Sales Person
|
||||
{'doctype': 'Sales Person', 'name': 'All Sales Persons', 'sales_person_name': 'All Sales Persons', 'is_group': "Yes", "parent_sales_person": ""},
|
||||
{'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""},
|
||||
|
||||
# UOM
|
||||
{'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Unit'},
|
||||
|
@ -27,7 +27,12 @@ class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
def autoname(self):
|
||||
suffix = " - " + webnotes.conn.get_value("Company", self.doc.company, "abbr")
|
||||
if not self.doc.warehouse_name.endswith(suffix):
|
||||
self.doc.name = self.doc.warehouse_name + suffix
|
||||
|
||||
def get_bin(self, item_code, warehouse=None):
|
||||
warehouse = warehouse or self.doc.name
|
||||
bin = sql("select name from tabBin where item_code = %s and \
|
||||
|
@ -2,13 +2,12 @@
|
||||
{
|
||||
"creation": "2013-03-07 18:50:32",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 18:37:24",
|
||||
"modified": "2013-07-10 18:46:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:warehouse_name",
|
||||
"description": "A logical Warehouse against which stock entries are made.",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
|
@ -77,12 +77,6 @@ wn.module_page["Website"] = [
|
||||
icon: "icon-wrench",
|
||||
right: true,
|
||||
items: [
|
||||
{
|
||||
"route":"Form/Product Settings",
|
||||
"label":wn._("Product Settings"),
|
||||
"description":wn._("Settings for Product Catalog on the website."),
|
||||
doctype:"Product Settings"
|
||||
},
|
||||
{
|
||||
"route":"Form/About Us Settings",
|
||||
"label":wn._("About Us Settings"),
|
||||
|
Loading…
Reference in New Issue
Block a user