fix: avoid creating bins without item-wh

Co-Authored-By:  Shadrak Gurupnor <30501401+shadrak98@users.noreply.github.com>
Co-Authored-By: Saurabh <saurabh6790@gmail.com>
This commit is contained in:
Ankush Menat 2022-02-17 19:25:00 +05:30 committed by Ankush Menat
parent bef46e2b64
commit c36bd7e1a6
4 changed files with 11 additions and 4 deletions

View File

@ -1955,7 +1955,8 @@ def update_bin_on_delete(row, doctype):
qty_dict["ordered_qty"] = get_ordered_qty(row.item_code, row.warehouse) qty_dict["ordered_qty"] = get_ordered_qty(row.item_code, row.warehouse)
update_bin_qty(row.item_code, row.warehouse, qty_dict) if row.warehouse:
update_bin_qty(row.item_code, row.warehouse, qty_dict)
def validate_and_delete_children(parent, data): def validate_and_delete_children(parent, data):
deleted_children = [] deleted_children = []

View File

@ -9,6 +9,8 @@ def execute():
FROM `tabBin`""",as_dict=1) FROM `tabBin`""",as_dict=1)
for entry in bin_details: for entry in bin_details:
if not (entry.item_code and entry.warehouse):
continue
update_bin_qty(entry.get("item_code"), entry.get("warehouse"), { update_bin_qty(entry.get("item_code"), entry.get("warehouse"), {
"indented_qty": get_indented_qty(entry.get("item_code"), entry.get("warehouse")) "indented_qty": get_indented_qty(entry.get("item_code"), entry.get("warehouse"))
}) })

View File

@ -29,9 +29,11 @@ def execute():
""") """)
for item_code, warehouse in repost_for: for item_code, warehouse in repost_for:
update_bin_qty(item_code, warehouse, { if not (item_code and warehouse):
"reserved_qty": get_reserved_qty(item_code, warehouse) continue
}) update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse)
})
frappe.db.sql("""delete from tabBin frappe.db.sql("""delete from tabBin
where exists( where exists(

View File

@ -14,6 +14,8 @@ def execute():
union union
select item_code, warehouse from `tabStock Ledger Entry`) a"""): select item_code, warehouse from `tabStock Ledger Entry`) a"""):
try: try:
if not (item_code and warehouse):
continue
count += 1 count += 1
update_bin_qty(item_code, warehouse, { update_bin_qty(item_code, warehouse, {
"indented_qty": get_indented_qty(item_code, warehouse), "indented_qty": get_indented_qty(item_code, warehouse),