Patch fixes
This commit is contained in:
parent
d3a32bc9e5
commit
06b0b36ae6
@ -80,13 +80,16 @@ def set_party_in_jv_and_gl_entry(receivable_payable_accounts):
|
||||
for dt in ["Journal Entry Account", "GL Entry"]:
|
||||
records = frappe.db.sql("""select name, account from `tab%s` where account in (%s)""" %
|
||||
(dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1)
|
||||
for d in records:
|
||||
for i, d in enumerate(records):
|
||||
account_details = account_map.get(d.account, {})
|
||||
account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable"
|
||||
new_account = receivable_payable_accounts[account_details.get("company")][account_type]
|
||||
|
||||
frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt),
|
||||
(new_account, account_details.get("master_type"), account_details.get("master_name"), d.name))
|
||||
|
||||
if i%500 == 0:
|
||||
frappe.db.commit()
|
||||
|
||||
def delete_individual_party_account():
|
||||
frappe.db.sql("""delete from `tabAccount` where ifnull(master_type, '') in ('Customer', 'Supplier')
|
||||
|
@ -4,7 +4,9 @@ def execute():
|
||||
# stock reco now amendable
|
||||
frappe.db.sql("""update tabDocPerm set `amend` = 1 where parent='Stock Reconciliation' and submit = 1""")
|
||||
|
||||
|
||||
frappe.reload_doc("stock", "doctype", "stock_reconciliation_item")
|
||||
frappe.reload_doctype("Stock Reconciliation")
|
||||
|
||||
if frappe.db.has_column("Stock Reconciliation", "reconciliation_json"):
|
||||
for sr in frappe.db.get_all("Stock Reconciliation", ["name"],
|
||||
{"reconciliation_json": ["!=", ""]}):
|
||||
@ -15,8 +17,8 @@ def execute():
|
||||
sr.append("items", {
|
||||
"item_code": row[0],
|
||||
"warehouse": row[1],
|
||||
"qty": row[3] if len(row) > 2 else None,
|
||||
"valuation_rate": row[4] if len(row) > 3 else None
|
||||
"qty": row[2] if len(row) > 2 else None,
|
||||
"valuation_rate": row[3] if len(row) > 3 else None
|
||||
})
|
||||
|
||||
elif row[0]=="Item Code":
|
||||
|
@ -7,16 +7,46 @@ from frappe.utils import cstr
|
||||
import re
|
||||
|
||||
def execute():
|
||||
item_details = frappe._dict()
|
||||
for d in frappe.db.sql("select name, description_html, description from `tabItem`", as_dict=1):
|
||||
description = cstr(d.description_html).strip() or cstr(d.description).strip()
|
||||
image_url, new_desc = extract_image_and_description(description)
|
||||
|
||||
item_details.setdefault(d.name, frappe._dict({
|
||||
"old_description": description,
|
||||
"new_description": new_desc,
|
||||
"image_url": image_url
|
||||
}))
|
||||
|
||||
|
||||
dt_list= ["Purchase Order Item","Supplier Quotation Item", "BOM", "BOM Explosion Item" , \
|
||||
"BOM Item", "Opportunity Item" , "Quotation Item" , "Sales Order Item" , "Delivery Note Item" , \
|
||||
"Material Request Item" , "Purchase Receipt Item" , "Stock Entry Detail"]
|
||||
for dt in dt_list:
|
||||
frappe.reload_doctype(dt)
|
||||
names = frappe.db.sql("""select name, description from `tab{0}` where description is not null""".format(dt),as_dict=1)
|
||||
for d in names:
|
||||
data = cstr(d.description)
|
||||
image_url = find_first_image(data)
|
||||
desc = re.sub("\<img[^>]+\>", "", data)
|
||||
records = frappe.db.sql("""select name, `{0}` as item_code, description from `tab{1}`
|
||||
where description is not null and image is null and description like '%%<img%%'"""
|
||||
.format("item" if dt=="BOM" else "item_code", dt), as_dict=1)
|
||||
|
||||
count = 1
|
||||
for d in records:
|
||||
if cstr(d.description) == item_details.get(d.item_code).old_description:
|
||||
image_url = item_details.get(d.item_code).image_url
|
||||
desc = item_details.get(d.item_code).new_description
|
||||
else:
|
||||
image_url, desc = extract_image_and_description(cstr(d.description))
|
||||
|
||||
frappe.db.sql("""update `tab{0}` set description = %s, image = %s
|
||||
where name = %s """.format(dt), (desc, image_url, d.name))
|
||||
if image_url:
|
||||
frappe.db.sql("""update `tab{0}` set description = %s, image = %s
|
||||
where name = %s """.format(dt), (desc, image_url, d.name))
|
||||
|
||||
count += 1
|
||||
if count % 500 == 0:
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
def extract_image_and_description(data):
|
||||
image_url = find_first_image(data)
|
||||
desc = re.sub("\<img[^>]+\>", "", data)
|
||||
|
||||
return image_url, desc
|
Loading…
x
Reference in New Issue
Block a user