From b3bc41131e9cac842d1f28936a0f962d1249d630 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 28 Sep 2016 18:17:52 +0530 Subject: [PATCH] Reposting of GLE and SLE for all stock transactions --- erpnext/accounts/doctype/account/account.py | 2 +- erpnext/stock/stock_balance.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index ced1e8516d..cedaf60f9f 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -171,7 +171,7 @@ class Account(Document): old_warehouse = cstr(frappe.db.get_value("Account", self.name, "warehouse")) if old_warehouse != cstr(self.warehouse): - if old_warehouse: + if old_warehouse and frappe.db.exists("Warehouse", old_warehouse): self.validate_warehouse(old_warehouse) if self.warehouse: self.validate_warehouse(self.warehouse) diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py index 22fa12a09b..096f6c07b6 100644 --- a/erpnext/stock/stock_balance.py +++ b/erpnext/stock/stock_balance.py @@ -230,7 +230,7 @@ def reset_serial_no_status_and_warehouse(serial_nos=None): pass def repost_all_stock_vouchers(): - warehouses_with_account = frappe.db.sql_list("""select master_name from tabAccount + warehouses_with_account = frappe.db.sql_list("""select warehouse from tabAccount where ifnull(account_type, '') = 'Stock' and (warehouse is not null and warehouse != '') and is_group=0""") @@ -244,7 +244,7 @@ def repost_all_stock_vouchers(): i = 0 for voucher_type, voucher_no in vouchers: i+=1 - print i, "/", len(vouchers) + print i, "/", len(vouchers), voucher_type, voucher_no try: for dt in ["Stock Ledger Entry", "GL Entry"]: frappe.db.sql("""delete from `tab%s` where voucher_type=%s and voucher_no=%s"""%