From 10007ab4df86323c6e5bbbb3100a3993b4021736 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 27 Jul 2016 12:43:02 +0530 Subject: [PATCH] [fix] reposting of gle where stock account not linked with warehouse --- ...nonwarehouse_ledger_gl_entries_for_transactions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py index af921dffed7..ff9d48a4e6a 100644 --- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py +++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py @@ -5,17 +5,22 @@ from __future__ import unicode_literals import frappe def execute(): + if not frappe.db.get_single_value("Accounts Settings", "auto_accounting_for_stock"): + return + frappe.reload_doctype("Account") warehouses = frappe.db.sql_list("""select name from tabAccount - where ifnull(account_type, '') = 'Stock' and ifnull(is_group, 0) = 0 - and warehouse is null""") + where account_type = 'Stock' and is_group = 0 + and (warehouse is null or warehouse = '')""") if warehouses: warehouses = set_warehouse_for_stock_account(warehouses) stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no from `tabStock Ledger Entry` sle - where sle.warehouse in (%s) + where sle.warehouse in (%s) and creation > '2016-05-01' + and not exists(select name from `tabGL Entry` + where account=sle.warehosue and voucher_type=sle.voucher_type and voucher_no=sle.voucher_no) order by sle.posting_date""" % ', '.join(['%s']*len(warehouses)), tuple(warehouses))