fix: wrong quantity after transaction for parallel stock transactions

When two transactions are inserted parallelly then previous SLE could be
incorrect for some of them. Locking SLE table would prevent reading from
it till transaction is complete.
This commit is contained in:
Ankush Menat 2021-05-21 12:12:42 +05:30
parent 814fd19424
commit 9979cf5fcc
No known key found for this signature in database
GPG Key ID: 8EA82E09BBD13AAF

View File

@ -232,7 +232,8 @@ class update_entries_after(object):
and is_cancelled = 0 and is_cancelled = 0
and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s)) and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s))
order by timestamp(posting_date, posting_time) desc, creation desc order by timestamp(posting_date, posting_time) desc, creation desc
limit 1""", args, as_dict=1) limit 1
for update""", args, as_dict=1)
return sle[0] if sle else frappe._dict() return sle[0] if sle else frappe._dict()