2016-05-26 12:11:39 +00:00
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
2016-05-27 07:14:18 +00:00
|
|
|
frappe.reload_doctype("GL Entry")
|
|
|
|
|
2016-05-26 12:11:39 +00:00
|
|
|
for doctype in ("Delivery Note", "Sales Invoice", "Stock Entry"):
|
|
|
|
frappe.db.sql("""
|
|
|
|
update `tabGL Entry` gle, `tab{0}` dt
|
|
|
|
set gle.project = dt.project
|
|
|
|
where gle.voucher_type=%s and gle.voucher_no = dt.name
|
|
|
|
and ifnull(gle.cost_center, '') != '' and ifnull(dt.project, '') != ''
|
|
|
|
""".format(doctype), doctype)
|
|
|
|
|
|
|
|
for doctype in ("Purchase Receipt", "Purchase Invoice"):
|
|
|
|
frappe.db.sql("""
|
|
|
|
update `tabGL Entry` gle, `tab{0} Item` dt
|
|
|
|
set gle.project = dt.project
|
|
|
|
where gle.voucher_type=%s and gle.voucher_no = dt.parent and gle.cost_center=dt.cost_center
|
|
|
|
and ifnull(gle.cost_center, '') != '' and ifnull(dt.project, '') != ''
|
|
|
|
""".format(doctype), doctype)
|