brotherton-erpnext/patches/march_2013/p10_update_against_expense_account.py
2013-11-20 13:00:28 +05:30

14 lines
614 B
Python

# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
def execute():
import webnotes
from webnotes import get_obj
pi_list = webnotes.conn.sql("""select name from `tabPurchase Invoice`
where docstatus = 1 and ifnull(against_expense_account, '') = ''""")
for pi in pi_list:
pi_obj = get_obj("Purchase Invoice", pi[0], with_children=1)
pi_obj.set_against_expense_account()
webnotes.conn.sql("""update `tabPurchase Invoice` set against_expense_account = %s
where name = %s""", (pi_obj.doc.against_expense_account, pi[0]))