How Frappe & ERPNext Handle with Record Lock?
Usually frappe always lock the record when a user load it.
In the UI, when you receive an messages, that the record have been modified, while saving, is because, someone or something raised an change on the record, and the active user have an outdated version of the record, preventing you to save it, before reload.
When you load or reload, frappe acquire the lock of the record for you, using an datetime stamp, and this is the mechanism to handle records locks.
Alternatively, some records will be enqueued to be synced with the database in background, because most of the time they are data intensive, and will acquire lock for many records at once.
For that case you can review the code of the controller for Stock Reconciliation
These records only will be unlocked when they are flushed from the queue