mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 23:19:20 +00:00
Merge pull request #48444 from mihir-kandoi/st42689
refactor: remove do_reposting_for_each_stock_transaction feature
This commit is contained in:
@@ -1771,14 +1771,9 @@ def is_reposting_pending():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def future_sle_exists(args, sl_entries=None, allow_force_reposting=True):
|
def future_sle_exists(args, sl_entries=None):
|
||||||
from erpnext.stock.utils import get_combine_datetime
|
from erpnext.stock.utils import get_combine_datetime
|
||||||
|
|
||||||
if allow_force_reposting and frappe.get_single_value(
|
|
||||||
"Stock Reposting Settings", "do_reposting_for_each_stock_transaction"
|
|
||||||
):
|
|
||||||
return True
|
|
||||||
|
|
||||||
key = (args.voucher_type, args.voucher_no)
|
key = (args.voucher_type, args.voucher_no)
|
||||||
if not hasattr(frappe.local, "future_sle"):
|
if not hasattr(frappe.local, "future_sle"):
|
||||||
frappe.local.future_sle = {}
|
frappe.local.future_sle = {}
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ def update_qty(bin_name, args):
|
|||||||
actual_qty = bin_details.actual_qty or 0.0
|
actual_qty = bin_details.actual_qty or 0.0
|
||||||
|
|
||||||
# actual qty is not up to date in case of backdated transaction
|
# actual qty is not up to date in case of backdated transaction
|
||||||
if future_sle_exists(args, allow_force_reposting=False):
|
if future_sle_exists(args):
|
||||||
actual_qty = get_actual_qty(args.get("item_code"), args.get("warehouse"))
|
actual_qty = get_actual_qty(args.get("item_code"), args.get("warehouse"))
|
||||||
|
|
||||||
ordered_qty = flt(bin_details.ordered_qty) + flt(args.get("ordered_qty"))
|
ordered_qty = flt(bin_details.ordered_qty) + flt(args.get("ordered_qty"))
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
"end_time",
|
"end_time",
|
||||||
"limits_dont_apply_on",
|
"limits_dont_apply_on",
|
||||||
"item_based_reposting",
|
"item_based_reposting",
|
||||||
"do_reposting_for_each_stock_transaction",
|
|
||||||
"errors_notification_section",
|
"errors_notification_section",
|
||||||
"notify_reposting_error_to_role"
|
"notify_reposting_error_to_role"
|
||||||
],
|
],
|
||||||
@@ -66,18 +65,12 @@
|
|||||||
"fieldname": "errors_notification_section",
|
"fieldname": "errors_notification_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Errors Notification"
|
"label": "Errors Notification"
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"fieldname": "do_reposting_for_each_stock_transaction",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"label": "Do reposting for each Stock Transaction"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-04-24 12:19:40.204888",
|
"modified": "2025-07-08 11:27:46.659056",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Reposting Settings",
|
"name": "Stock Reposting Settings",
|
||||||
@@ -94,8 +87,9 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"row_format": "Dynamic",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ class StockRepostingSettings(Document):
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from frappe.types import DF
|
from frappe.types import DF
|
||||||
|
|
||||||
do_reposting_for_each_stock_transaction: DF.Check
|
|
||||||
end_time: DF.Time | None
|
end_time: DF.Time | None
|
||||||
item_based_reposting: DF.Check
|
item_based_reposting: DF.Check
|
||||||
limit_reposting_timeslot: DF.Check
|
limit_reposting_timeslot: DF.Check
|
||||||
@@ -30,10 +29,6 @@ class StockRepostingSettings(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_minimum_reposting_time_slot()
|
self.set_minimum_reposting_time_slot()
|
||||||
|
|
||||||
def before_save(self):
|
|
||||||
if self.do_reposting_for_each_stock_transaction:
|
|
||||||
self.item_based_reposting = 1
|
|
||||||
|
|
||||||
def set_minimum_reposting_time_slot(self):
|
def set_minimum_reposting_time_slot(self):
|
||||||
"""Ensure that timeslot for reposting is at least 12 hours."""
|
"""Ensure that timeslot for reposting is at least 12 hours."""
|
||||||
if not self.limit_reposting_timeslot:
|
if not self.limit_reposting_timeslot:
|
||||||
|
|||||||
@@ -38,51 +38,3 @@ class TestStockRepostingSettings(IntegrationTestCase):
|
|||||||
|
|
||||||
users = get_recipients()
|
users = get_recipients()
|
||||||
self.assertTrue(user in users)
|
self.assertTrue(user in users)
|
||||||
|
|
||||||
def test_do_reposting_for_each_stock_transaction(self):
|
|
||||||
from erpnext.stock.doctype.item.test_item import make_item
|
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
|
||||||
|
|
||||||
frappe.db.set_single_value("Stock Reposting Settings", "do_reposting_for_each_stock_transaction", 1)
|
|
||||||
if frappe.db.get_single_value("Stock Reposting Settings", "item_based_reposting"):
|
|
||||||
frappe.db.set_single_value("Stock Reposting Settings", "item_based_reposting", 0)
|
|
||||||
|
|
||||||
item = make_item(
|
|
||||||
"_Test item for reposting check for each transaction", properties={"is_stock_item": 1}
|
|
||||||
).name
|
|
||||||
|
|
||||||
stock_entry = make_stock_entry(
|
|
||||||
item_code=item,
|
|
||||||
qty=1,
|
|
||||||
rate=100,
|
|
||||||
stock_entry_type="Material Receipt",
|
|
||||||
target="_Test Warehouse - _TC",
|
|
||||||
)
|
|
||||||
|
|
||||||
riv = frappe.get_all("Repost Item Valuation", filters={"voucher_no": stock_entry.name}, pluck="name")
|
|
||||||
self.assertTrue(riv)
|
|
||||||
|
|
||||||
frappe.db.set_single_value("Stock Reposting Settings", "do_reposting_for_each_stock_transaction", 0)
|
|
||||||
|
|
||||||
def test_do_not_reposting_for_each_stock_transaction(self):
|
|
||||||
from erpnext.stock.doctype.item.test_item import make_item
|
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
|
||||||
|
|
||||||
frappe.db.set_single_value("Stock Reposting Settings", "do_reposting_for_each_stock_transaction", 0)
|
|
||||||
if frappe.db.get_single_value("Stock Reposting Settings", "item_based_reposting"):
|
|
||||||
frappe.db.set_single_value("Stock Reposting Settings", "item_based_reposting", 0)
|
|
||||||
|
|
||||||
item = make_item(
|
|
||||||
"_Test item for do not reposting check for each transaction", properties={"is_stock_item": 1}
|
|
||||||
).name
|
|
||||||
|
|
||||||
stock_entry = make_stock_entry(
|
|
||||||
item_code=item,
|
|
||||||
qty=1,
|
|
||||||
rate=100,
|
|
||||||
stock_entry_type="Material Receipt",
|
|
||||||
target="_Test Warehouse - _TC",
|
|
||||||
)
|
|
||||||
|
|
||||||
riv = frappe.get_all("Repost Item Valuation", filters={"voucher_no": stock_entry.name}, pluck="name")
|
|
||||||
self.assertFalse(riv)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user