From 0b8254e69b9ce90391b56f774c3fa8a6f1c10ccf Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 2 Sep 2013 17:17:48 +0530 Subject: [PATCH] [fix] [minor] recreate gl entries when using auto inventory accounting to fix bug introduced due to commit - 5dd6b1d082d180133813c1c661d5e72076a19491 --- .../september_2013/p01_fix_buying_amount_gl_entries.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/patches/september_2013/p01_fix_buying_amount_gl_entries.py b/patches/september_2013/p01_fix_buying_amount_gl_entries.py index 011180a58a0..369a2914f1a 100644 --- a/patches/september_2013/p01_fix_buying_amount_gl_entries.py +++ b/patches/september_2013/p01_fix_buying_amount_gl_entries.py @@ -25,6 +25,9 @@ def recreate_gl_entries(doctype, name, parentfield): bean = webnotes.bean(doctype, name) bean.run_method("set_buying_amount") + company_values = webnotes.conn.get_value("Company", bean.doc.company, ["default_expense_account", + "stock_adjustment_account", "cost_center", "stock_adjustment_cost_center"]) + # update missing expense account and cost center for item in bean.doclist.get({"parentfield": parentfield}): if item.buying_amount and not validate_item_values(item, bean.doc.company): @@ -38,9 +41,12 @@ def recreate_gl_entries(doctype, name, parentfield): if res: item.expense_account = res[0][0] item.cost_center = res[0][1] + elif company_values: + item.expense_account = company_values[0] or company_values[1] + item.cost_center = company_values[2] or company_values[3] - webnotes.conn.set_value(item.doctype, item.name, "expense_account", item.expense_account) - webnotes.conn.set_value(item.doctype, item.name, "cost_center", item.cost_center) + webnotes.conn.set_value(item.doctype, item.name, "expense_account", item.expense_account) + webnotes.conn.set_value(item.doctype, item.name, "cost_center", item.cost_center) # remove gl entries webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type=%s