mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-12 14:58:24 +00:00
fix: reposting creation slow for GL entries
This commit is contained in:
@@ -237,7 +237,8 @@
|
||||
"fieldname": "reposting_reference",
|
||||
"fieldtype": "Data",
|
||||
"label": "Reposting Reference",
|
||||
"read_only": 1
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -252,7 +253,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2025-12-24 14:59:15.512898",
|
||||
"modified": "2026-02-25 14:22:21.681549",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Repost Item Valuation",
|
||||
|
||||
@@ -470,7 +470,15 @@ def repost_gl_entries(doc):
|
||||
repost_affected_transaction = get_affected_transactions(doc)
|
||||
|
||||
transactions = directly_dependent_transactions + list(repost_affected_transaction)
|
||||
if doc.based_on == "Item and Warehouse" and not doc.repost_only_accounting_ledgers:
|
||||
enable_separate_reposting_for_gl = frappe.db.get_single_value(
|
||||
"Stock Reposting Settings", "enable_separate_reposting_for_gl"
|
||||
)
|
||||
|
||||
if (
|
||||
enable_separate_reposting_for_gl
|
||||
and doc.based_on == "Item and Warehouse"
|
||||
and not doc.repost_only_accounting_ledgers
|
||||
):
|
||||
make_reposting_for_accounting_ledgers(
|
||||
transactions,
|
||||
doc.company,
|
||||
@@ -671,25 +679,43 @@ def execute_repost_item_valuation():
|
||||
|
||||
|
||||
def make_reposting_for_accounting_ledgers(transactions, company, repost_doc):
|
||||
reposting_map = get_existing_reposting_only_gl_entries(repost_doc.name)
|
||||
|
||||
for voucher_type, voucher_no in transactions:
|
||||
if frappe.db.exists(
|
||||
"Repost Item Valuation",
|
||||
{
|
||||
"voucher_type": voucher_type,
|
||||
"voucher_no": voucher_no,
|
||||
"docstatus": 1,
|
||||
"reposting_reference": repost_doc.name,
|
||||
"repost_only_accounting_ledgers": 1,
|
||||
"status": "Queued",
|
||||
},
|
||||
):
|
||||
if reposting_map.get((voucher_type, voucher_no)):
|
||||
continue
|
||||
|
||||
new_repost_doc = frappe.new_doc("Repost Item Valuation")
|
||||
new_repost_doc.company = company
|
||||
new_repost_doc.voucher_type = voucher_type
|
||||
new_repost_doc.voucher_no = voucher_no
|
||||
new_repost_doc.repost_only_accounting_ledgers = 1
|
||||
new_repost_doc.reposting_reference = repost_doc.name
|
||||
new_repost_doc.flags.ignore_permissions = True
|
||||
new_repost_doc.submit()
|
||||
try:
|
||||
new_repost_doc = frappe.new_doc("Repost Item Valuation")
|
||||
new_repost_doc.company = company
|
||||
new_repost_doc.voucher_type = voucher_type
|
||||
new_repost_doc.voucher_no = voucher_no
|
||||
new_repost_doc.repost_only_accounting_ledgers = 1
|
||||
new_repost_doc.reposting_reference = repost_doc.name
|
||||
new_repost_doc.flags.ignore_permissions = True
|
||||
new_repost_doc.submit()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def get_existing_reposting_only_gl_entries(reposting_reference):
|
||||
existing_reposting = frappe.get_all(
|
||||
"Repost Item Valuation",
|
||||
filters={
|
||||
"reposting_reference": reposting_reference,
|
||||
"docstatus": 1,
|
||||
"status": "Queued",
|
||||
"repost_only_accounting_ledgers": 1,
|
||||
},
|
||||
fields=["reposting_reference", "voucher_type", "voucher_no"],
|
||||
)
|
||||
|
||||
if not existing_reposting:
|
||||
return frappe._dict()
|
||||
|
||||
reposting_map = {}
|
||||
for d in existing_reposting:
|
||||
key = (d.voucher_type, d.voucher_no)
|
||||
reposting_map[key] = d.reposting_reference
|
||||
|
||||
return reposting_map
|
||||
|
||||
@@ -13,8 +13,11 @@
|
||||
"end_time",
|
||||
"limits_dont_apply_on",
|
||||
"item_based_reposting",
|
||||
"section_break_dxuf",
|
||||
"enable_parallel_reposting",
|
||||
"no_of_parallel_reposting",
|
||||
"column_break_itvd",
|
||||
"enable_separate_reposting_for_gl",
|
||||
"errors_notification_section",
|
||||
"notify_reposting_error_to_role"
|
||||
],
|
||||
@@ -81,13 +84,28 @@
|
||||
"fieldname": "no_of_parallel_reposting",
|
||||
"fieldtype": "Int",
|
||||
"label": "No of Parallel Reposting (Per Item)"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_dxuf",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_itvd",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "item_based_reposting",
|
||||
"fieldname": "enable_separate_reposting_for_gl",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Separate Reposting for GL"
|
||||
}
|
||||
],
|
||||
"hide_toolbar": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2026-01-02 18:18:57.115176",
|
||||
"modified": "2026-02-25 14:11:33.461173",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Reposting Settings",
|
||||
|
||||
@@ -17,6 +17,7 @@ class StockRepostingSettings(Document):
|
||||
from frappe.types import DF
|
||||
|
||||
enable_parallel_reposting: DF.Check
|
||||
enable_separate_reposting_for_gl: DF.Check
|
||||
end_time: DF.Time | None
|
||||
item_based_reposting: DF.Check
|
||||
limit_reposting_timeslot: DF.Check
|
||||
|
||||
Reference in New Issue
Block a user