diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 705ea42d7f9..4974d08fb8f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -479,4 +479,4 @@ erpnext.patches.v16_0.merge_repost_settings_to_accounts_settings erpnext.patches.v16_0.set_root_type_in_account_categories erpnext.patches.v16_0.scr_inv_dimension erpnext.patches.v16_0.packed_item_inv_dimen -erpnext.patches.v16_0.correct_po_titles +erpnext.patches.v16_0.fix_titles diff --git a/erpnext/patches/v16_0/correct_po_titles.py b/erpnext/patches/v16_0/correct_po_titles.py deleted file mode 100644 index 04334e52ca7..00000000000 --- a/erpnext/patches/v16_0/correct_po_titles.py +++ /dev/null @@ -1,15 +0,0 @@ -import frappe - - -def execute(): - """ - This patch corrects the titles of purchase orders that were set to - the text string "{supplier_name}" instead of the actual supplier name. - """ - - purchase_order = frappe.qb.DocType("Purchase Order") - ( - frappe.qb.update(purchase_order) - .set(purchase_order.title, purchase_order.supplier_name) - .where(purchase_order.title == "{supplier_name}") - ).run() diff --git a/erpnext/patches/v16_0/fix_titles.py b/erpnext/patches/v16_0/fix_titles.py new file mode 100644 index 00000000000..1bcd3cb6737 --- /dev/null +++ b/erpnext/patches/v16_0/fix_titles.py @@ -0,0 +1,28 @@ +import frappe + + +def execute(): + """ + This patch corrects the titles of doctypes set to + the text strings "{customer_name}" or "{supplier_name}" + instead of the actual customer or supplier name. + """ + + customer_doctypes = ["POS Invoice", "Sales Invoice", "Quotation", "Sales Order", "Delivery Note"] + supplier_doctypes = ["Purchase Invoice", "Purchase Order", "Purchase Receipt"] + + for doctype in customer_doctypes: + customer_doctype = frappe.qb.DocType(doctype) + ( + frappe.qb.update(customer_doctype) + .set(customer_doctype.title, customer_doctype.customer_name) + .where(customer_doctype.title == "{customer_name}") + ).run() + + for doctype in supplier_doctypes: + supplier_doctype = frappe.qb.DocType(doctype) + ( + frappe.qb.update(supplier_doctype) + .set(supplier_doctype.title, supplier_doctype.supplier_name) + .where(supplier_doctype.title == "{supplier_name}") + ).run()