[fix] [minor] recreate gl entries when using auto inventory accounting to fix bug introduced due to commit - 5dd6b1d082

This commit is contained in:
Anand Doshi
2013-09-02 16:34:49 +05:30
parent d09039ae43
commit fe73c38867

View File

@@ -32,18 +32,6 @@ def recreate_gl_entries(doctype, name, parentfield):
# update missing expense account and cost center # update missing expense account and cost center
for item in bean.doclist.get({"parentfield": parentfield}): for item in bean.doclist.get({"parentfield": parentfield}):
if item.buying_amount and not (item.expense_account and item.cost_center): if item.buying_amount and not (item.expense_account and item.cost_center):
item_values = webnotes.conn.get_value("Item", item.item_code,
["purchase_account", "default_sales_cost_center"])
company_values = webnotes.conn.get_value("Company", bean.doc.company,
["default_expense_account", "cost_center", "stock_adjustment_cost_center"])
if not item.expense_account:
item.expense_account = (item_values and item_values[0]) or (company_values and company_values[0])
if not item.cost_center:
item.cost_center = (item_values and item_values[1]) or \
(company_values and (company_values[1] or company_values[2]))
if not (item.expense_account and item.cost_center):
res = webnotes.conn.sql("""select expense_account, cost_center res = webnotes.conn.sql("""select expense_account, cost_center
from `tab%s` child where docstatus=1 and item_code=%s and from `tab%s` child where docstatus=1 and item_code=%s and
ifnull(expense_account, '')!='' and ifnull(cost_center, '')!='' and ifnull(expense_account, '')!='' and ifnull(cost_center, '')!='' and