From b0b446e89950b764793d4de5006aa990e09bb66f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 29 May 2015 12:43:39 +0530 Subject: [PATCH] [fix] cleanup tables from description and re-sync print format --- .../cheque_printing_format.json | 26 +++++----- erpnext/patches.txt | 1 + .../v5_0/update_item_and_description_again.py | 49 +++++++++++++++++++ .../v5_0/update_item_description_and_image.py | 16 +++--- .../includes/item_table_description.html | 4 +- 5 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 erpnext/patches/v5_0/update_item_and_description_again.py diff --git a/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json b/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json index 9421d4540f..8c9c26691e 100755 --- a/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json +++ b/erpnext/accounts/print_format/cheque_printing_format/cheque_printing_format.json @@ -1,15 +1,15 @@ { - "creation": "2012-04-11 13:16:56", - "doc_type": "Journal Entry", - "docstatus": 0, - "doctype": "Print Format", - "html": "
\n\n\t{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n
\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Payment Advice\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n{%- for label, value in (\n (_(\"Voucher Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Reference / Cheque No.\"), doc.cheque_no),\n (_(\"Reference / Cheque Date\"), frappe.utils.formatdate(doc.cheque_date))\n ) -%}\n
\n
\n
{{ value }}
\n
\n{%- endfor -%}\n\t
\n\t

{{ _(\"This amount is in full / part settlement of the listed bills\") }}:

\n{%- for label, value in (\n (_(\"Amount\"), \"\" + doc.get_formatted(\"total_amount\") + \"
\" + (doc.total_amount_in_words or \"\") + \"
\"),\n (_(\"References\"), doc.remark)\n ) -%}\n
\n
\n
{{ value }}
\n
\n {%- endfor -%}\n
\n\t
\n\t\tPrepared By
\n\t
\n\t\tAuthorised Signatory
\n\t
\n\t\tReceived Payment as Above
\n\t
\n\t\t_____________
\n\t
\n\t\tA/C Payee
\n\t
\n\t\t_____________
\n\t
\n\t\t{{ frappe.utils.formatdate(doc.cheque_date) }}
\n\t
\n\t\t{{ doc.pay_to_recd_from }}
\n\t
\n\t\t{{ doc.total_amount_in_words }}
\n\t
\n\t\t{{ doc.total_amount }}
\n
", - "idx": 1, - "modified": "2015-01-12 11:03:17.032512", - "modified_by": "Administrator", - "module": "Accounts", - "name": "Cheque Printing Format", - "owner": "Administrator", - "print_format_type": "Server", + "creation": "2012-04-11 13:16:56", + "custom_format": 1, + "doc_type": "Journal Entry", + "docstatus": 0, + "doctype": "Print Format", + "html": "
\n\n\t{%- from \"templates/print_formats/standard_macros.html\" import add_header -%}\n
\n {%- if not doc.get(\"print_heading\") and not doc.get(\"select_print_heading\") \n and doc.set(\"select_print_heading\", _(\"Payment Advice\")) -%}{%- endif -%}\n {{ add_header(0, 1, doc, letter_head, no_letterhead) }}\n\n{%- for label, value in (\n (_(\"Voucher Date\"), frappe.utils.formatdate(doc.voucher_date)),\n (_(\"Reference / Cheque No.\"), doc.cheque_no),\n (_(\"Reference / Cheque Date\"), frappe.utils.formatdate(doc.cheque_date))\n ) -%}\n
\n
\n
{{ value }}
\n
\n{%- endfor -%}\n\t
\n\t

{{ _(\"This amount is in full / part settlement of the listed bills\") }}:

\n{%- for label, value in (\n (_(\"Amount\"), \"\" + doc.get_formatted(\"total_amount\") + \"
\" + (doc.total_amount_in_words or \"\") + \"
\"),\n (_(\"References\"), doc.remark)\n ) -%}\n
\n
\n
{{ value }}
\n
\n {%- endfor -%}\n
\n\t
\n\t\tPrepared By
\n\t
\n\t\tAuthorised Signatory
\n\t
\n\t\tReceived Payment as Above
\n\t
\n\t\t_____________
\n\t
\n\t\tA/C Payee
\n\t
\n\t\t_____________
\n\t
\n\t\t{{ frappe.utils.formatdate(doc.cheque_date) }}
\n\t
\n\t\t{{ doc.pay_to_recd_from }}
\n\t
\n\t\t{{ doc.total_amount_in_words }}
\n\t
\n\t\t{{ doc.get_formatted(\"total_amount\") }}
\n
", + "idx": 1, + "modified": "2015-05-29 01:57:51.203850", + "modified_by": "Administrator", + "name": "Cheque Printing Format", + "owner": "Administrator", + "print_format_type": "Server", "standard": "Yes" -} +} \ No newline at end of file diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 813b1fc6fe..f9590a9fe0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -160,3 +160,4 @@ erpnext.patches.v5_0.update_operation_description erpnext.patches.v5_0.set_footer_address execute:frappe.db.set_value("Backup Manager", None, "send_backups_to_dropbox", 1 if frappe.db.get_value("Backup Manager", None, "upload_backups_to_dropbox") in ("Daily", "Weekly") else 0) execute:frappe.db.sql_list("delete from `tabDocPerm` where parent='Issue' and modified_by='Administrator' and role='Guest'") +erpnext.patches.v5_0.update_item_and_description_again diff --git a/erpnext/patches/v5_0/update_item_and_description_again.py b/erpnext/patches/v5_0/update_item_and_description_again.py new file mode 100644 index 0000000000..622274807a --- /dev/null +++ b/erpnext/patches/v5_0/update_item_and_description_again.py @@ -0,0 +1,49 @@ +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +import frappe +from frappe.utils import cstr +import re + +def execute(): + item_details = frappe._dict() + for d in frappe.db.sql("select name, description from `tabItem`", as_dict=1): + description = cstr(d.description).strip() + new_desc = extract_description(description) + + item_details.setdefault(d.name, frappe._dict({ + "old_description": description, + "new_description": new_desc + })) + + + 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) + records = frappe.db.sql("""select name, `{0}` as item_code, description from `tab{1}` + where description is not null and description like '%%]*\>".format(tag), "", desc) + + return desc 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 6b4705205e..a18df2f653 100644 --- a/erpnext/patches/v5_0/update_item_description_and_image.py +++ b/erpnext/patches/v5_0/update_item_description_and_image.py @@ -11,23 +11,23 @@ def execute(): 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) - records = frappe.db.sql("""select name, `{0}` as item_code, description from `tab{1}` + 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 + + return image_url, desc diff --git a/erpnext/templates/print_formats/includes/item_table_description.html b/erpnext/templates/print_formats/includes/item_table_description.html index e0824a20f9..34f95b9f27 100644 --- a/erpnext/templates/print_formats/includes/item_table_description.html +++ b/erpnext/templates/print_formats/includes/item_table_description.html @@ -1,5 +1,5 @@ {% if doc.in_format_data("image") and doc.get("image") and not doc.is_print_hide("image")-%} -
+
{%- endif %} @@ -8,7 +8,7 @@
{{ doc.item_code }}
{%- endif %} {% if (doc.in_format_data("item_name") and - (not doc.in_format_data("item_code") or doc.is_print_hide("item_code") + (not doc.in_format_data("item_code") or doc.is_print_hide("item_code") or doc.item_code != doc.item_name)) -%}
{{ doc.get_formatted("item_name") }}
{%- endif %}