fix: bypass validation during reposting

(cherry picked from commit 3697b9fd9b)
(cherry picked from commit 01aad96b10)
This commit is contained in:
Rohit Waghchaure
2025-04-09 23:47:55 +05:30
committed by Mergify
parent 52257c946e
commit eaaac6e596
2 changed files with 16 additions and 0 deletions

View File

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

View File

@@ -322,6 +322,15 @@ class SerialandBatchBundle(Document):
else: else:
valuation_rate = valuation_details["batches"].get(row.batch_no) 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.incoming_rate = flt(valuation_rate)
row.stock_value_difference = flt(row.qty) * flt(row.incoming_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) self.set_incoming_rate_for_inward_transaction(row, save)
def validate_returned_serial_batch_no(self, return_against, row, original_inv_details): 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"]: if row.serial_no and row.serial_no not in original_inv_details["serial_nos"]:
self.throw_error_message( self.throw_error_message(
_( _(