diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c4529e576e9..91e063b1d81 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -470,7 +470,7 @@ erpnext.patches.v16_0.add_portal_redirects erpnext.patches.v16_0.update_order_qty_and_requested_qty_based_on_mr_and_po erpnext.patches.v16_0.complete_onboarding_steps_for_older_sites #2 erpnext.patches.v16_0.enable_serial_batch_setting -erpnext.patches.v16_0.correct_po_titles +erpnext.patches.v16_0.fix_titles erpnext.patches.v16_0.co_by_product_patch erpnext.patches.v16_0.update_requested_qty_packed_item erpnext.patches.v16_0.remove_payables_receivables_workspace 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()