Merge pull request #46978 from rohitwaghchaure/fixed-support-32497

fix: bypass validation during reposting
This commit is contained in:
rohitwaghchaure
2025-04-10 11:42:20 +05:30
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -4038,6 +4038,8 @@ class TestPurchaseReceipt(IntegrationTestCase):
make_purchase_return,
)
frappe.flags.through_repost_item_valuation = False
sn_item_code = make_item(
"Test Serial No for Validation", {"has_serial_no": 1, "serial_no_series": "SN-TSNFVAL-.#####"}
).name
@@ -4069,6 +4071,8 @@ class TestPurchaseReceipt(IntegrationTestCase):
make_purchase_return,
)
frappe.flags.through_repost_item_valuation = False
batch_item_code = make_item(
"Test Batch No for Validation",
{"has_batch_no": 1, "batch_number_series": "BT-TSNFVAL-.#####", "create_new_batch": 1},

View File

@@ -322,6 +322,15 @@ class SerialandBatchBundle(Document):
else:
valuation_rate = valuation_details["batches"].get(row.batch_no)
if frappe.flags.through_repost_item_valuation and not valuation_rate:
# if different serial nos / batches are returned
if row.serial_no:
serial_nos = sorted(list(valuation_details["serial_nos"].keys()))
valuation_rate = valuation_details["serial_nos"].get(serial_nos[cint(row.idx) - 1])
else:
batches = sorted(list(valuation_details["batches"].keys()))
valuation_rate = valuation_details["batches"].get(batches[cint(row.idx) - 1])
row.incoming_rate = flt(valuation_rate)
row.stock_value_difference = flt(row.qty) * flt(row.incoming_rate)
@@ -337,6 +346,9 @@ class SerialandBatchBundle(Document):
self.set_incoming_rate_for_inward_transaction(row, save)
def validate_returned_serial_batch_no(self, return_against, row, original_inv_details):
if frappe.flags.through_repost_item_valuation:
return
if row.serial_no and row.serial_no not in original_inv_details["serial_nos"]:
self.throw_error_message(
_(