Skip to content

Commit

Permalink
fix: timeout error while submitting stock entry
Browse files Browse the repository at this point in the history
Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit a05c47e)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Dec 23, 2022
1 parent 81d82c1 commit f30f77c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions erpnext/stock/doctype/bin/bin.py
Expand Up @@ -162,6 +162,7 @@ def update_qty(bin_name, args):
.where((sle.item_code == args.get("item_code")) & (sle.warehouse == args.get("warehouse")))
.orderby(CombineDatetime(sle.posting_date, sle.posting_time), order=Order.desc)
.orderby(sle.creation, order=Order.desc)
.limit(1)
.run()
)

Expand Down
23 changes: 18 additions & 5 deletions erpnext/stock/stock_ledger.py
Expand Up @@ -470,8 +470,10 @@ def get_sle_against_current_voucher(self):
item_code = %(item_code)s
and warehouse = %(warehouse)s
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 (
posting_date = %(posting_date)s and
time_format(posting_time, %(time_format)s) = time_format(%(posting_time)s, %(time_format)s)
)
order by
creation ASC
for update
Expand Down Expand Up @@ -1070,7 +1072,13 @@ def get_previous_sle_of_current_voucher(args, exclude_current_voucher=False):
and warehouse = %(warehouse)s
and is_cancelled = 0
{voucher_condition}
and timestamp(posting_date, time_format(posting_time, %(time_format)s)) < timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s))
and (
posting_date < %(posting_date)s or
(
posting_date = %(posting_date)s and
time_format(posting_time, %(time_format)s) < time_format(%(posting_time)s, %(time_format)s)
)
)
order by timestamp(posting_date, posting_time) desc, creation desc
limit 1
for update""".format(
Expand Down Expand Up @@ -1355,8 +1363,13 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
and warehouse = %(warehouse)s
and voucher_no != %(voucher_no)s
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 (
posting_date > %(posting_date)s or
(
posting_date = %(posting_date)s and
time_format(posting_time, %(time_format)s) > time_format(%(posting_time)s, %(time_format)s)
)
)
{datetime_limit_condition}
""",
args,
Expand Down

0 comments on commit f30f77c

Please sign in to comment.