diff --git a/erpnext/patches/v5_4/stock_entry_additional_costs.py b/erpnext/patches/v5_4/stock_entry_additional_costs.py index 325d6cf4a4..3a98deb918 100644 --- a/erpnext/patches/v5_4/stock_entry_additional_costs.py +++ b/erpnext/patches/v5_4/stock_entry_additional_costs.py @@ -10,12 +10,6 @@ def execute(): frappe.reload_doctype("Stock Entry Detail") frappe.reload_doctype("Landed Cost Taxes and Charges") - frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se - set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount - where sed.parent = se.name - and (se.purpose not in ('Manufacture', 'Repack') or ifnull(additional_operating_cost, 0)=0) - """) - stock_entry_db_columns = frappe.db.get_table_columns("Stock Entry") if "additional_operating_cost" in stock_entry_db_columns: operating_cost_fieldname = "additional_operating_cost" @@ -25,6 +19,13 @@ def execute(): return + frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se + set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount + where sed.parent = se.name + and (se.purpose not in ('Manufacture', 'Repack') or ifnull({0}, 0)=0) + """.format(operating_cost_fieldname)) + + stock_entries = frappe.db.sql_list("""select name from `tabStock Entry` where purpose in ('Manufacture', 'Repack') and ifnull({0}, 0)!=0 and docstatus < 2""".format(operating_cost_fieldname))