fix: timeout error while submitting stock entry

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
Rohit Waghchaure 2022-12-22 10:24:04 +05:30
parent 65db9cea25
commit a05c47e499
2 changed files with 19 additions and 5 deletions

View File

@ -162,6 +162,7 @@ def update_qty(bin_name, args):
.where((sle.item_code == args.get("item_code")) & (sle.warehouse == args.get("warehouse"))) .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(CombineDatetime(sle.posting_date, sle.posting_time), order=Order.desc)
.orderby(sle.creation, order=Order.desc) .orderby(sle.creation, order=Order.desc)
.limit(1)
.run() .run()
) )

View File

@ -470,8 +470,10 @@ class update_entries_after(object):
item_code = %(item_code)s item_code = %(item_code)s
and warehouse = %(warehouse)s and warehouse = %(warehouse)s
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 (
posting_date = %(posting_date)s and
time_format(posting_time, %(time_format)s) = time_format(%(posting_time)s, %(time_format)s)
)
order by order by
creation ASC creation ASC
for update for update
@ -1070,7 +1072,13 @@ def get_previous_sle_of_current_voucher(args, exclude_current_voucher=False):
and warehouse = %(warehouse)s and warehouse = %(warehouse)s
and is_cancelled = 0 and is_cancelled = 0
{voucher_condition} {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 order by timestamp(posting_date, posting_time) desc, creation desc
limit 1 limit 1
for update""".format( for update""".format(
@ -1355,8 +1363,13 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
and warehouse = %(warehouse)s and warehouse = %(warehouse)s
and voucher_no != %(voucher_no)s and voucher_no != %(voucher_no)s
and is_cancelled = 0 and is_cancelled = 0
and timestamp(posting_date, time_format(posting_time, %(time_format)s)) and (
> timestamp(%(posting_date)s, time_format(%(posting_time)s, %(time_format)s)) 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} {datetime_limit_condition}
""", """,
args, args,