From 8e523961dc8dae52b90e8f0c98aeee37f3880d9a Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Tue, 24 Oct 2023 14:13:26 +0530 Subject: [PATCH] fix(patch): `update_sre_from_voucher_details` (#37649) --- .../v15_0/update_sre_from_voucher_details.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/erpnext/patches/v15_0/update_sre_from_voucher_details.py b/erpnext/patches/v15_0/update_sre_from_voucher_details.py index a9653ccbf4..06ba553e3a 100644 --- a/erpnext/patches/v15_0/update_sre_from_voucher_details.py +++ b/erpnext/patches/v15_0/update_sre_from_voucher_details.py @@ -3,13 +3,16 @@ from frappe.query_builder.functions import IfNull def execute(): - sre = frappe.qb.DocType("Stock Reservation Entry") - ( - frappe.qb.update(sre) - .set(sre.from_voucher_type, "Pick List") - .set(sre.from_voucher_no, sre.against_pick_list) - .set(sre.from_voucher_detail_no, sre.against_pick_list_item) - .where( - (IfNull(sre.against_pick_list, "") != "") & (IfNull(sre.against_pick_list_item, "") != "") - ) - ).run() + columns = frappe.db.get_table_columns("Stock Reservation Entry") + + if set(["against_pick_list", "against_pick_list_item"]).issubset(set(columns)): + sre = frappe.qb.DocType("Stock Reservation Entry") + ( + frappe.qb.update(sre) + .set(sre.from_voucher_type, "Pick List") + .set(sre.from_voucher_no, sre.against_pick_list) + .set(sre.from_voucher_detail_no, sre.against_pick_list_item) + .where( + (IfNull(sre.against_pick_list, "") != "") & (IfNull(sre.against_pick_list_item, "") != "") + ) + ).run()