Merge branch 'responsive' of github.com:webnotes/erpnext into responsive

This commit is contained in:
Nabin Hait
2013-07-10 19:12:14 +05:30
23 changed files with 100 additions and 320 deletions

View File

@@ -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):
"""

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-10 08:35:39",
"docstatus": 0,
"modified": "2013-07-08 17:34:21",
"modified": "2013-07-10 18:17:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -52,6 +52,17 @@
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "company_name",
"fieldtype": "Data",
"label": "Company",
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"read_only": 0,
"reqd": 1
},
{
"description": "Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.",
"doctype": "DocField",
@@ -72,13 +83,10 @@
},
{
"doctype": "DocField",
"fieldname": "company_name",
"fieldtype": "Data",
"label": "Company",
"no_copy": 0,
"oldfieldname": "company_name",
"oldfieldtype": "Data",
"read_only": 0,
"fieldname": "domain",
"fieldtype": "Select",
"label": "Domain",
"options": "Distribution\nManufacturing\nRetail\nServices",
"reqd": 1
},
{