brotherton-erpnext/erpnext/patches/v7_0/update_project_in_gl_entry.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
793 B
Python
Raw Normal View History

from __future__ import unicode_literals
import frappe
def execute():
2016-05-27 07:14:18 +00:00
frappe.reload_doctype("GL Entry")
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)