fix: circular dependency during reposting causing timeout error
This commit is contained in:
parent
b16f364866
commit
c16a5814d4
@ -1956,6 +1956,32 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
ste5.reload()
|
ste5.reload()
|
||||||
self.assertEqual(ste5.items[0].valuation_rate, 275.00)
|
self.assertEqual(ste5.items[0].valuation_rate, 275.00)
|
||||||
|
|
||||||
|
ste6 = make_stock_entry(
|
||||||
|
purpose="Material Transfer",
|
||||||
|
posting_date=add_days(today(), -3),
|
||||||
|
source=warehouse1,
|
||||||
|
target=warehouse,
|
||||||
|
item_code=item_code,
|
||||||
|
qty=20,
|
||||||
|
company=pr.company,
|
||||||
|
)
|
||||||
|
|
||||||
|
ste6.reload()
|
||||||
|
self.assertEqual(ste6.items[0].valuation_rate, 275.00)
|
||||||
|
|
||||||
|
ste7 = make_stock_entry(
|
||||||
|
purpose="Material Transfer",
|
||||||
|
posting_date=add_days(today(), -3),
|
||||||
|
source=warehouse,
|
||||||
|
target=warehouse1,
|
||||||
|
item_code=item_code,
|
||||||
|
qty=20,
|
||||||
|
company=pr.company,
|
||||||
|
)
|
||||||
|
|
||||||
|
ste7.reload()
|
||||||
|
self.assertEqual(ste7.items[0].valuation_rate, 275.00)
|
||||||
|
|
||||||
create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company, charges=2500 * -1)
|
create_landed_cost_voucher("Purchase Receipt", pr.name, pr.company, charges=2500 * -1)
|
||||||
|
|
||||||
pr.reload()
|
pr.reload()
|
||||||
@ -1976,6 +2002,12 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
ste5.reload()
|
ste5.reload()
|
||||||
self.assertEqual(ste5.items[0].valuation_rate, valuation_rate)
|
self.assertEqual(ste5.items[0].valuation_rate, valuation_rate)
|
||||||
|
|
||||||
|
ste6.reload()
|
||||||
|
self.assertEqual(ste6.items[0].valuation_rate, valuation_rate)
|
||||||
|
|
||||||
|
ste7.reload()
|
||||||
|
self.assertEqual(ste7.items[0].valuation_rate, valuation_rate)
|
||||||
|
|
||||||
|
|
||||||
def prepare_data_for_internal_transfer():
|
def prepare_data_for_internal_transfer():
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
||||||
|
@ -645,7 +645,7 @@ class update_entries_after(object):
|
|||||||
|
|
||||||
def update_distinct_item_warehouses(self, dependant_sle):
|
def update_distinct_item_warehouses(self, dependant_sle):
|
||||||
key = (dependant_sle.item_code, dependant_sle.warehouse)
|
key = (dependant_sle.item_code, dependant_sle.warehouse)
|
||||||
val = frappe._dict({"sle": dependant_sle})
|
val = frappe._dict({"sle": dependant_sle, "dependent_voucher_detail_nos": []})
|
||||||
|
|
||||||
if key not in self.distinct_item_warehouses:
|
if key not in self.distinct_item_warehouses:
|
||||||
self.distinct_item_warehouses[key] = val
|
self.distinct_item_warehouses[key] = val
|
||||||
@ -654,13 +654,26 @@ class update_entries_after(object):
|
|||||||
existing_sle_posting_date = (
|
existing_sle_posting_date = (
|
||||||
self.distinct_item_warehouses[key].get("sle", {}).get("posting_date")
|
self.distinct_item_warehouses[key].get("sle", {}).get("posting_date")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dependent_voucher_detail_nos = self.get_dependent_voucher_detail_nos(key)
|
||||||
|
|
||||||
if getdate(dependant_sle.posting_date) < getdate(existing_sle_posting_date):
|
if getdate(dependant_sle.posting_date) < getdate(existing_sle_posting_date):
|
||||||
val.sle_changed = True
|
val.sle_changed = True
|
||||||
self.distinct_item_warehouses[key] = val
|
self.distinct_item_warehouses[key] = val
|
||||||
self.new_items_found = True
|
self.new_items_found = True
|
||||||
elif self.distinct_item_warehouses[key].get("reposting_status"):
|
elif dependant_sle.voucher_detail_no not in set(dependent_voucher_detail_nos):
|
||||||
self.distinct_item_warehouses[key] = val
|
# Future dependent voucher needs to be repost to get the correct stock value
|
||||||
|
# If dependent voucher has not reposted, then add it to the list
|
||||||
|
dependent_voucher_detail_nos.append(dependant_sle.voucher_detail_no)
|
||||||
self.new_items_found = True
|
self.new_items_found = True
|
||||||
|
val.dependent_voucher_detail_nos = dependent_voucher_detail_nos
|
||||||
|
self.distinct_item_warehouses[key] = val
|
||||||
|
|
||||||
|
def get_dependent_voucher_detail_nos(self, key):
|
||||||
|
if "dependent_voucher_detail_nos" not in self.distinct_item_warehouses[key]:
|
||||||
|
self.distinct_item_warehouses[key].dependent_voucher_detail_nos = []
|
||||||
|
|
||||||
|
return self.distinct_item_warehouses[key].dependent_voucher_detail_nos
|
||||||
|
|
||||||
def process_sle(self, sle):
|
def process_sle(self, sle):
|
||||||
# previous sle data for this warehouse
|
# previous sle data for this warehouse
|
||||||
@ -1370,6 +1383,7 @@ def get_sle_by_voucher_detail_no(voucher_detail_no, excluded_sle=None):
|
|||||||
"qty_after_transaction",
|
"qty_after_transaction",
|
||||||
"posting_date",
|
"posting_date",
|
||||||
"posting_time",
|
"posting_time",
|
||||||
|
"voucher_detail_no",
|
||||||
"timestamp(posting_date, posting_time) as timestamp",
|
"timestamp(posting_date, posting_time) as timestamp",
|
||||||
],
|
],
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user