Merge pull request #3941 from nabinhait/fix2
[fix] Stock Entry additional costs patch fix for v4 accounts
diff --git a/erpnext/patches/v5_4/stock_entry_additional_costs.py b/erpnext/patches/v5_4/stock_entry_additional_costs.py
index 325d6cf..3a98deb 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 @@
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 @@
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))