[files] [patch] dropped file_list property and moved links to

This commit is contained in:
Rushabh Mehta
2013-04-10 11:08:50 +05:30
37 changed files with 733 additions and 496 deletions

View File

@@ -0,0 +1,12 @@
import webnotes
import webnotes.model
def execute():
for p in ["activity", "todo", "questions", "question-view"]:
pbean = webnotes.bean("Page", p)
if len(pbean.doclist) == 1:
pbean.doclist.append({
"doctype": "Page Role",
"role": "All",
"parentfield": "roles"
})
pbean.save()

View File

@@ -0,0 +1,47 @@
import webnotes, webnotes.utils, os
from webnotes.modules.export_file import export_to_files
def execute():
singles = webnotes.conn.sql_list("""select name from tabDocType
where ifnull(issingle,0)=1""")
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
fieldname='file_list' and fieldtype='Text'"""):
print doctype
if doctype in singles:
doc = webnotes.doc(doctype, doctype)
update_for_doc(doctype, doc)
webnotes.conn.set_value(doctype, None, "file_list", None)
else:
try:
for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
ifnull(file_list, '')!=''""" % doctype, as_dict=True):
update_for_doc(doctype, doc)
webnotes.conn.commit()
webnotes.conn.sql("""alter table `tab%s` drop column file_list""" % doctype)
except Exception, e:
if e.args[0]!=1054: raise e
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
and parent=%s""", doctype)
export_to_files([["DocType", doctype]])
def update_for_doc(doctype, doc):
for filedata in doc.file_list.split("\n"):
if not filedata:
continue
filename, fileid = filedata.split(",")
exists = True
if not (filename.startswith("http://") or filename.startswith("https://")):
if not os.path.exists(os.path.join(webnotes.utils.get_base_path(), "public", "files", filename)):
exists = False
if exists:
webnotes.conn.sql("""update `tabFile Data`
set attached_to_doctype=%s, attached_to_name=%s
where name=%s""", (doctype, doc.name, fileid))
else:
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
fileid)

View File

@@ -2,13 +2,18 @@ import webnotes
def execute():
webnotes.reload_doc("accounts", "doctype", "purchase_invoice_item")
webnotes.conn.auto_commit_on_many_writes = True
for purchase_invoice in webnotes.conn.sql_list("""select distinct parent
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(valuation_rate, 0)=0"""):
pi = webnotes.get_obj("Purchase Invoice", purchase_invoice)
pi.calculate_taxes_and_totals()
try:
pi.calculate_taxes_and_totals()
except:
pass
pi.update_raw_material_cost()
pi.update_valuation_rate("entries")
for item in pi.doclist.get({"parentfield": "entries"}):
webnotes.conn.sql("""update `tabPurchase Invoice Item` set valuation_rate = %s
where name = %s""", (item.valuation_rate, item.name))
webnotes.conn.auto_commit_on_many_writes = False

View File

@@ -1,7 +1,7 @@
import webnotes
def execute():
webnotes.reload_doc("setup", "doctype", "company")
create_chart_of_accounts_if_not_exists()
add_group_accounts()
add_ledger_accounts()
add_aii_cost_center()
@@ -94,4 +94,10 @@ def add_aii_cost_center():
})
cc.insert()
def create_chart_of_accounts_if_not_exists():
for company in webnotes.conn.sql("select name from `tabCompany`"):
if not webnotes.conn.sql("select * from `tabAccount` where company = %s", company[0]):
webnotes.conn.sql("""update `tabCompany` set receivables_group = '',
payables_group = '' where name = %s""", company[0])
webnotes.bean("Company", company[0]).save()

View File

@@ -239,5 +239,6 @@ patch_list = [
'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Modern") # 2013-04-02',
'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Spartan") # 2013-04-02',
"patches.april_2013.p04_reverse_modules_list",
"execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')"
"execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')",
"patches.april_2013.p04_update_role_in_pages",
]