mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
[fix] [minor] only post sl entries if stock item exists
This commit is contained in:
@@ -11,29 +11,31 @@ import json
|
|||||||
class NegativeStockError(webnotes.ValidationError): pass
|
class NegativeStockError(webnotes.ValidationError): pass
|
||||||
|
|
||||||
def make_sl_entries(sl_entries, is_amended=None):
|
def make_sl_entries(sl_entries, is_amended=None):
|
||||||
from stock.utils import update_bin
|
if sl_entries:
|
||||||
|
from stock.utils import update_bin
|
||||||
|
|
||||||
cancel = True if sl_entries[0].get("is_cancelled") == "Yes" else False
|
cancel = True if sl_entries[0].get("is_cancelled") == "Yes" else False
|
||||||
if cancel:
|
if cancel:
|
||||||
set_as_cancel(sl_entries[0].get('voucher_no'), sl_entries[0].get('voucher_type'))
|
set_as_cancel(sl_entries[0].get('voucher_no'), sl_entries[0].get('voucher_type'))
|
||||||
|
|
||||||
for sle in sl_entries:
|
for sle in sl_entries:
|
||||||
sle_id = None
|
sle_id = None
|
||||||
if sle.get('is_cancelled') == 'Yes':
|
if sle.get('is_cancelled') == 'Yes':
|
||||||
sle['actual_qty'] = -flt(sle['actual_qty'])
|
sle['actual_qty'] = -flt(sle['actual_qty'])
|
||||||
|
|
||||||
if sle.get("actual_qty"):
|
if sle.get("actual_qty"):
|
||||||
sle_id = make_entry(sle)
|
sle_id = make_entry(sle)
|
||||||
|
|
||||||
args = sle.copy()
|
args = sle.copy()
|
||||||
args.update({
|
args.update({
|
||||||
"sle_id": sle_id,
|
"sle_id": sle_id,
|
||||||
"is_amended": is_amended
|
"is_amended": is_amended
|
||||||
})
|
})
|
||||||
update_bin(args)
|
update_bin(args)
|
||||||
|
|
||||||
if cancel:
|
if cancel:
|
||||||
delete_cancelled_entry(sl_entries[0].get('voucher_type'), sl_entries[0].get('voucher_no'))
|
delete_cancelled_entry(sl_entries[0].get('voucher_type'),
|
||||||
|
sl_entries[0].get('voucher_no'))
|
||||||
|
|
||||||
def set_as_cancel(voucher_type, voucher_no):
|
def set_as_cancel(voucher_type, voucher_no):
|
||||||
webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled='Yes',
|
||||||
|
|||||||
Reference in New Issue
Block a user