From 6e6ef83d60d3f42b32b2d578889e8bd5f0f2e62b Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 15 May 2026 13:49:41 +0530 Subject: [PATCH 1/5] fix: incoming rate for legacy serial no (cherry picked from commit 2773b7c0022bbad0e872d05289fdfedeac0a79f7) # Conflicts: # erpnext/stock/deprecated_serial_batch.py # erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json # erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py --- erpnext/stock/deprecated_serial_batch.py | 19 +++++- .../stock_reposting_settings.json | 58 +++++++++++++++++++ .../stock_reposting_settings.py | 6 ++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index 6c30b087de8..e1a64b3547b 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -32,9 +32,26 @@ class DeprecatedSerialNoValuation: # get rate from serial nos within same company incoming_values = 0.0 +<<<<<<< HEAD +======= + posting_datetime = self.sle.posting_datetime + + if not posting_datetime and self.sle.posting_date: + posting_datetime = get_combine_datetime(self.sle.posting_date, self.sle.posting_time) + + do_not_fetch_rate = frappe.db.get_single_value( + "Stock Reposting Settings", "do_not_fetch_incoming_rate_from_serial_no" + ) + +>>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) for serial_no in serial_nos: sn_details = frappe.db.get_value("Serial No", serial_no, ["purchase_rate", "company"], as_dict=1) - if sn_details and sn_details.purchase_rate and sn_details.company == self.sle.company: + if ( + sn_details + and sn_details.purchase_rate + and sn_details.company == self.sle.company + and (not frappe.flags.through_repost_item_valuation or not do_not_fetch_rate) + ): self.serial_no_incoming_rate[serial_no] += flt(sn_details.purchase_rate) incoming_values += self.serial_no_incoming_rate[serial_no] continue diff --git a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json index 3137bedfee4..de638582630 100644 --- a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json +++ b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json @@ -1,5 +1,6 @@ { "actions": [], + "allow_bulk_edit": 1, "allow_rename": 1, "beta": 1, "creation": "2021-10-01 10:56:30.814787", @@ -13,6 +14,16 @@ "end_time", "limits_dont_apply_on", "item_based_reposting", +<<<<<<< HEAD +======= + "column_break_mavd", + "do_not_fetch_incoming_rate_from_serial_no", + "section_break_dxuf", + "enable_parallel_reposting", + "no_of_parallel_reposting", + "column_break_itvd", + "enable_separate_reposting_for_gl", +>>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) "errors_notification_section", "notify_reposting_error_to_role" ], @@ -65,12 +76,59 @@ "fieldname": "errors_notification_section", "fieldtype": "Section Break", "label": "Errors Notification" +<<<<<<< HEAD +======= + }, + { + "default": "0", + "depends_on": "eval: doc.item_based_reposting", + "fieldname": "enable_parallel_reposting", + "fieldtype": "Check", + "label": "Enable Parallel Reposting" + }, + { + "default": "4", + "depends_on": "eval: doc.item_based_reposting === 1 && doc.enable_parallel_reposting === 1", + "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" + }, + { + "fieldname": "column_break_mavd", + "fieldtype": "Column Break" + }, + { + "default": "0", + "description": "For legacy serial nos, do not fetch incoming rate from serial no and calculate it based on the inward transaction", + "fieldname": "do_not_fetch_incoming_rate_from_serial_no", + "fieldtype": "Check", + "label": "Do not fetch incoming rate from Serial No" +>>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2025-07-08 11:27:46.659056", +======= + "modified": "2026-05-15 12:59:34.392491", +>>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) "modified_by": "Administrator", "module": "Stock", "name": "Stock Reposting Settings", diff --git a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py index 8b47cd88df6..8b905c481d4 100644 --- a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py +++ b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py @@ -16,6 +16,12 @@ class StockRepostingSettings(Document): if TYPE_CHECKING: from frappe.types import DF +<<<<<<< HEAD +======= + do_not_fetch_incoming_rate_from_serial_no: DF.Check + enable_parallel_reposting: DF.Check + enable_separate_reposting_for_gl: DF.Check +>>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) end_time: DF.Time | None item_based_reposting: DF.Check limit_reposting_timeslot: DF.Check From 08466218d8bb5c71d511bbc402b67328fff31716 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 21 May 2026 14:28:29 +0530 Subject: [PATCH 2/5] chore: fix conflicts Removed legacy code for fetching incoming rates from serial numbers. --- erpnext/stock/deprecated_serial_batch.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index e1a64b3547b..6702067e5fc 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -32,18 +32,6 @@ class DeprecatedSerialNoValuation: # get rate from serial nos within same company incoming_values = 0.0 -<<<<<<< HEAD -======= - posting_datetime = self.sle.posting_datetime - - if not posting_datetime and self.sle.posting_date: - posting_datetime = get_combine_datetime(self.sle.posting_date, self.sle.posting_time) - - do_not_fetch_rate = frappe.db.get_single_value( - "Stock Reposting Settings", "do_not_fetch_incoming_rate_from_serial_no" - ) - ->>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) for serial_no in serial_nos: sn_details = frappe.db.get_value("Serial No", serial_no, ["purchase_rate", "company"], as_dict=1) if ( From 5557e982bf68d755865ba1af2718e6ff88ce1775 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 21 May 2026 14:30:26 +0530 Subject: [PATCH 3/5] chore: fix conflicts Removed legacy fields related to incoming rate and parallel reposting. --- .../stock_reposting_settings/stock_reposting_settings.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py index 8b905c481d4..c2b3d81c5c7 100644 --- a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py +++ b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.py @@ -16,12 +16,7 @@ class StockRepostingSettings(Document): if TYPE_CHECKING: from frappe.types import DF -<<<<<<< HEAD -======= do_not_fetch_incoming_rate_from_serial_no: DF.Check - enable_parallel_reposting: DF.Check - enable_separate_reposting_for_gl: DF.Check ->>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) end_time: DF.Time | None item_based_reposting: DF.Check limit_reposting_timeslot: DF.Check From 6981599103db1bfcabc513df81c74de156cdb507 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 21 May 2026 14:31:22 +0530 Subject: [PATCH 4/5] chore: fix conflicts Removed fields related to parallel reposting and column breaks, and updated the modified date. --- .../stock_reposting_settings.json | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json index de638582630..81f4bda30e4 100644 --- a/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json +++ b/erpnext/stock/doctype/stock_reposting_settings/stock_reposting_settings.json @@ -14,16 +14,7 @@ "end_time", "limits_dont_apply_on", "item_based_reposting", -<<<<<<< HEAD -======= - "column_break_mavd", "do_not_fetch_incoming_rate_from_serial_no", - "section_break_dxuf", - "enable_parallel_reposting", - "no_of_parallel_reposting", - "column_break_itvd", - "enable_separate_reposting_for_gl", ->>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) "errors_notification_section", "notify_reposting_error_to_role" ], @@ -76,41 +67,6 @@ "fieldname": "errors_notification_section", "fieldtype": "Section Break", "label": "Errors Notification" -<<<<<<< HEAD -======= - }, - { - "default": "0", - "depends_on": "eval: doc.item_based_reposting", - "fieldname": "enable_parallel_reposting", - "fieldtype": "Check", - "label": "Enable Parallel Reposting" - }, - { - "default": "4", - "depends_on": "eval: doc.item_based_reposting === 1 && doc.enable_parallel_reposting === 1", - "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" - }, - { - "fieldname": "column_break_mavd", - "fieldtype": "Column Break" }, { "default": "0", @@ -118,17 +74,12 @@ "fieldname": "do_not_fetch_incoming_rate_from_serial_no", "fieldtype": "Check", "label": "Do not fetch incoming rate from Serial No" ->>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD - "modified": "2025-07-08 11:27:46.659056", -======= "modified": "2026-05-15 12:59:34.392491", ->>>>>>> 2773b7c002 (fix: incoming rate for legacy serial no) "modified_by": "Administrator", "module": "Stock", "name": "Stock Reposting Settings", From da8d25d80ada32ccdf2dc903d78ec52d512afd26 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 21 May 2026 14:38:05 +0530 Subject: [PATCH 5/5] chore: fix linters issue Added a setting to control fetching incoming rates for serial numbers. --- erpnext/stock/deprecated_serial_batch.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/stock/deprecated_serial_batch.py b/erpnext/stock/deprecated_serial_batch.py index 6702067e5fc..00a06e98d2e 100644 --- a/erpnext/stock/deprecated_serial_batch.py +++ b/erpnext/stock/deprecated_serial_batch.py @@ -30,6 +30,10 @@ class DeprecatedSerialNoValuation: def get_incoming_value_for_serial_nos(self, serial_nos): from erpnext.stock.utils import get_combine_datetime + do_not_fetch_rate = frappe.db.get_single_value( + "Stock Reposting Settings", "do_not_fetch_incoming_rate_from_serial_no" + ) + # get rate from serial nos within same company incoming_values = 0.0 for serial_no in serial_nos: