mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 05:59:18 +00:00
[aii] [patches] minor fixes
This commit is contained in:
@@ -2,6 +2,9 @@ import webnotes
|
||||
from webnotes.utils import now_datetime
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("stock", "doctype", "delivery_note_item")
|
||||
webnotes.reload_doc("accounts", "doctype", "sales_invoice_item")
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = True
|
||||
for company in webnotes.conn.sql("select name from `tabCompany`"):
|
||||
print company[0]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.reload_doc("accounts", "doctype", "purchase_invoice_item")
|
||||
|
||||
for purchase_invoice in webnotes.conn.sql_list("""select distinct parent
|
||||
from `tabPurchase Invoice Item` pi_item where docstatus = 1 and ifnull(valuation_rate, 0)=0
|
||||
and exists(select name from `tabPurchase Invoice` where name = pi_item.parent)"""):
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import webnotes
|
||||
def execute():
|
||||
webnotes.reload_doc("setup", "doctype", "company")
|
||||
|
||||
add_group_accounts()
|
||||
add_ledger_accounts()
|
||||
add_aii_cost_center()
|
||||
set_default_accounts()
|
||||
|
||||
def set_default_accounts():
|
||||
for company in webnotes.conn.sql_list("select name from `tabCompany`"):
|
||||
webnotes.get_obj("Company", company).set_default_accounts()
|
||||
|
||||
def _check(parent_account, company):
|
||||
def _get_root(is_pl_account, debit_or_credit):
|
||||
@@ -45,6 +52,14 @@ def add_ledger_accounts():
|
||||
|
||||
def add_accounts(accounts_to_add, check_fn=None):
|
||||
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
|
||||
count = webnotes.conn.sql("""select count(name) from `tabAccount`
|
||||
where company=%s and ifnull(parent_account, '')=''""", company)[0][0]
|
||||
|
||||
if count > 4:
|
||||
print "Company", company, \
|
||||
"has more than 4 root accounts. cannot apply patch to this company."
|
||||
continue
|
||||
|
||||
for account_name, parent_account_name, group_or_ledger, account_type in accounts_to_add:
|
||||
if not webnotes.conn.exists("Account", "%s - %s" % (account_name, abbr)):
|
||||
parent_account = "%s - %s" % (parent_account_name, abbr)
|
||||
@@ -64,7 +79,11 @@ def add_aii_cost_center():
|
||||
for company, abbr in webnotes.conn.sql("""select name, abbr from `tabCompany`"""):
|
||||
if not webnotes.conn.exists("Cost Center", "Auto Inventory Accounting - %s" % abbr):
|
||||
parent_cost_center = webnotes.conn.get_value("Cost Center",
|
||||
{"parent_cost_center['']": '', "company_name": company}, 'name')
|
||||
{"parent_cost_center['']": '', "company_name": company})
|
||||
|
||||
if not parent_cost_center:
|
||||
print "Company", company, "does not have a root cost center"
|
||||
continue
|
||||
|
||||
cc = webnotes.bean({
|
||||
"doctype": "Cost Center",
|
||||
|
||||
Reference in New Issue
Block a user