Merge pull request #24754 from rohitwaghchaure/fixed-repost-item-valuation-patch
fix: reposting patch
diff --git a/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py b/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
index ca04e8a..3200363 100644
--- a/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
+++ b/erpnext/patches/v13_0/item_reposting_for_incorrect_sl_and_gl.py
@@ -7,7 +7,7 @@
def execute():
frappe.reload_doc('stock', 'doctype', 'repost_item_valuation')
- reposting_project_deployed_on = frappe.db.get_value("DocType", "Repost Item Valuation", "creation")
+ reposting_project_deployed_on = get_creation_time()
data = frappe.db.sql('''
SELECT
@@ -48,3 +48,7 @@
update_gl_entries_after(posting_date, posting_time, company=row.name)
frappe.db.auto_commit_on_many_writes = 0
+
+def get_creation_time():
+ return frappe.db.sql(''' SELECT create_time FROM
+ INFORMATION_SCHEMA.TABLES where TABLE_NAME = "tabRepost Item Valuation" ''', as_list=1)[0][0]
\ No newline at end of file
diff --git a/erpnext/stock/__init__.py b/erpnext/stock/__init__.py
index 9e240cc..283f7d5 100644
--- a/erpnext/stock/__init__.py
+++ b/erpnext/stock/__init__.py
@@ -38,7 +38,7 @@
frappe.flags.warehouse_account_map[company] = warehouse_account
else:
frappe.flags.warehouse_account_map = warehouse_account
-
+
return frappe.flags.warehouse_account_map.get(company) or frappe.flags.warehouse_account_map
def get_warehouse_account(warehouse, warehouse_account=None):
@@ -64,6 +64,10 @@
if not account and warehouse.company:
account = get_company_default_inventory_account(warehouse.company)
+ if not account and warehouse.company:
+ account = frappe.db.get_value('Account',
+ {'account_type': 'Stock', 'is_group': 0, 'company': warehouse.company}, 'name')
+
if not account and warehouse.company and not warehouse.is_group:
frappe.throw(_("Please set Account in Warehouse {0} or Default Inventory Account in Company {1}")
.format(warehouse.name, warehouse.company))