From e9b445c8531230d7860df5098a4c94ab911660e9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 24 Aug 2015 16:55:02 +0530 Subject: [PATCH] [fix] Stock Entry additional costs patch fix for v4 accounts --- .../patches/v5_4/stock_entry_additional_costs.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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))