brotherton-erpnext/erpnext/patches/v5_0/update_companywise_payment_account.py

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

22 lines
760 B
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2015-03-02 07:31:39 +00:00
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('accounts', 'doctype', 'mode_of_payment')
frappe.reload_doc('accounts', 'doctype', 'mode_of_payment_account')
mode_of_payment_list = frappe.db.sql("""select name, default_account
from `tabMode of Payment`""", as_dict=1)
for d in mode_of_payment_list:
if d.get("default_account"):
parent_doc = frappe.get_doc("Mode of Payment", d.get("name"))
parent_doc.set("accounts",
2015-01-14 06:36:20 +00:00
[{"company": frappe.db.get_value("Account", d.get("default_account"), "company"),
"default_account": d.get("default_account")}])
parent_doc.save()