From 06b0b36ae6201b6542a3095e71cfb7d6b50595c4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 25 Mar 2015 14:51:05 +0530 Subject: [PATCH] Patch fixes --- erpnext/patches/v4_2/party_model.py | 5 ++- .../v5_0/convert_stock_reconciliation.py | 8 ++-- .../v5_0/update_item_description_and_image.py | 44 ++++++++++++++++--- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py index be681a8427..bb4ff0bf2c 100644 --- a/erpnext/patches/v4_2/party_model.py +++ b/erpnext/patches/v4_2/party_model.py @@ -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') diff --git a/erpnext/patches/v5_0/convert_stock_reconciliation.py b/erpnext/patches/v5_0/convert_stock_reconciliation.py index cc9135a081..8a0b93d9d8 100644 --- a/erpnext/patches/v5_0/convert_stock_reconciliation.py +++ b/erpnext/patches/v5_0/convert_stock_reconciliation.py @@ -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": diff --git a/erpnext/patches/v5_0/update_item_description_and_image.py b/erpnext/patches/v5_0/update_item_description_and_image.py index d91c9180f8..7e61314b7a 100644 --- a/erpnext/patches/v5_0/update_item_description_and_image.py +++ b/erpnext/patches/v5_0/update_item_description_and_image.py @@ -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("\]+\>", "", 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 '%%]+\>", "", data) + + return image_url, desc \ No newline at end of file