fix: update bin modified timestamp when updating qty

These timestamps are used for writing integrations hence whenever bin is
updated timestamp should update to reliabily use Bin for integration
logic.
This commit is contained in:
Ankush Menat 2022-02-11 11:29:37 +05:30 committed by Ankush Menat
parent 1553fa9c90
commit 77be98295c
2 changed files with 5 additions and 3 deletions
erpnext
buying/doctype/purchase_order
stock

View File

@ -682,17 +682,18 @@ class TestPurchaseOrder(unittest.TestCase):
bin1 = frappe.db.get_value("Bin",
filters={"warehouse": "_Test Warehouse - _TC", "item_code": "_Test Item"},
fieldname=["reserved_qty_for_sub_contract", "projected_qty"], as_dict=1)
fieldname=["reserved_qty_for_sub_contract", "projected_qty", "modified"], as_dict=1)
# Submit PO
po = create_purchase_order(item_code="_Test FG Item", is_subcontracted="Yes")
bin2 = frappe.db.get_value("Bin",
filters={"warehouse": "_Test Warehouse - _TC", "item_code": "_Test Item"},
fieldname=["reserved_qty_for_sub_contract", "projected_qty"], as_dict=1)
fieldname=["reserved_qty_for_sub_contract", "projected_qty", "modified"], as_dict=1)
self.assertEqual(bin2.reserved_qty_for_sub_contract, bin1.reserved_qty_for_sub_contract + 10)
self.assertEqual(bin2.projected_qty, bin1.projected_qty - 10)
self.assertNotEqual(bin1.modified, bin2.modified)
# Create stock transfer
rm_item = [{"item_code":"_Test FG Item","rm_item_code":"_Test Item","item_name":"_Test Item",

View File

@ -3,7 +3,7 @@
import frappe
from frappe.utils import cstr, flt, nowdate, nowtime
from frappe.utils import cstr, flt, now, nowdate, nowtime
from erpnext.controllers.stock_controller import create_repost_item_valuation_entry
@ -174,6 +174,7 @@ def update_bin_qty(item_code, warehouse, qty_dict=None):
bin.set(field, flt(value))
mismatch = True
bin.modified = now()
if mismatch:
bin.set_projected_qty()
bin.db_update()