[fix] [minor] recreate gl entries when using auto inventory accounting to fix bug introduced due to commit - 5dd6b1d082d180133813c1c661d5e72076a19491
This commit is contained in:
parent
fe73c38867
commit
79401717e0
@ -21,10 +21,6 @@ def execute():
|
|||||||
recreate_gl_entries("Sales Invoice", si, "entries")
|
recreate_gl_entries("Sales Invoice", si, "entries")
|
||||||
|
|
||||||
def recreate_gl_entries(doctype, name, parentfield):
|
def recreate_gl_entries(doctype, name, parentfield):
|
||||||
# remove gl entries
|
|
||||||
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type=%s
|
|
||||||
and voucher_no=%s""", (doctype, name))
|
|
||||||
|
|
||||||
# calculate buying amount and make gl entries
|
# calculate buying amount and make gl entries
|
||||||
bean = webnotes.bean(doctype, name)
|
bean = webnotes.bean(doctype, name)
|
||||||
bean.run_method("set_buying_amount")
|
bean.run_method("set_buying_amount")
|
||||||
@ -35,16 +31,20 @@ def recreate_gl_entries(doctype, name, parentfield):
|
|||||||
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
|
||||||
(select company from `tab%s` parent where parent.name=child.parent)=%s
|
(select company from `tabAccount` ac where ac.name=child.expense_account)=%s and
|
||||||
order by creation desc limit 1""" % (item.doctype, "%s", doctype, "%s"),
|
(select company from `tabCost Center` cc where cc.name=child.cost_center)=%s
|
||||||
(item.item_code, bean.doc.company))
|
order by creation desc limit 1""" % (item.doctype, "%s", "%s", "%s"),
|
||||||
|
(item.item_code, bean.doc.company, bean.doc.company))
|
||||||
if res:
|
if res:
|
||||||
if not item.expense_account:
|
if not item.expense_account:
|
||||||
item.expense_account = res[0][0]
|
item.expense_account = res[0][0]
|
||||||
if not item.cost_center:
|
if not item.cost_center:
|
||||||
item.cost_center = res[0][1]
|
item.cost_center = res[0][1]
|
||||||
|
|
||||||
webnotes.conn.set_value(item.doctype, item.name, "expense_account", item.expense_account)
|
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, "cost_center", item.cost_center)
|
||||||
|
|
||||||
|
# remove gl entries
|
||||||
|
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type=%s
|
||||||
|
and voucher_no=%s""", (doctype, name))
|
||||||
bean.run_method("make_gl_entries")
|
bean.run_method("make_gl_entries")
|
||||||
Loading…
x
Reference in New Issue
Block a user