[fix][patch] Reserved Qty logic fixed and reposted for existing items
This commit is contained in:
parent
df469c3e02
commit
1826791891
@ -188,7 +188,7 @@ class SellingController(StockController):
|
||||
reserved_qty_for_main_item = -(so_qty - already_delivered_qty)
|
||||
else:
|
||||
reserved_qty_for_main_item = -flt(d.qty)
|
||||
|
||||
|
||||
if self.has_product_bundle(d.item_code):
|
||||
for p in self.get("packed_items"):
|
||||
if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
|
||||
@ -229,10 +229,12 @@ class SellingController(StockController):
|
||||
and against_sales_order = %s
|
||||
and parent != %s""", (so_detail, so, current_docname))
|
||||
|
||||
delivered_via_si = frappe.db.sql("""select sum(qty) from `tabSales Invoice Item`
|
||||
where so_detail = %s and docstatus = 1
|
||||
and sales_order = %s
|
||||
and parent != %s""", (so_detail, so, current_docname))
|
||||
delivered_via_si = frappe.db.sql("""select sum(si_item.qty)
|
||||
from `tabSales Invoice Item` si_item, `tabSales Invoice` si
|
||||
where si_item.parent = si.name and ifnull(si.update_stock, 0) = 1
|
||||
and si_item.so_detail = %s and si.docstatus = 1
|
||||
and si_item.sales_order = %s
|
||||
and si.name != %s""", (so_detail, so, current_docname))
|
||||
|
||||
total_delivered_qty = (flt(delivered_via_dn[0][0]) if delivered_via_dn else 0) \
|
||||
+ (flt(delivered_via_si[0][0]) if delivered_via_si else 0)
|
||||
|
@ -137,7 +137,6 @@ erpnext.patches.v5_0.update_account_types
|
||||
erpnext.patches.v5_0.update_sms_sender
|
||||
erpnext.patches.v5_0.set_appraisal_remarks
|
||||
erpnext.patches.v5_0.update_time_log_title
|
||||
erpnext.patches.v4_2.repost_reserved_qty
|
||||
erpnext.patches.v4_2.repost_sle_for_si_with_no_warehouse
|
||||
erpnext.patches.v5_0.newsletter
|
||||
execute:frappe.delete_doc("DocType", "Chart of Accounts")
|
||||
@ -192,3 +191,4 @@ erpnext.patches.v5_4.stock_entry_additional_costs
|
||||
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
|
||||
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
|
||||
erpnext.patches.v5_7.item_template_attributes
|
||||
erpnext.patches.v4_2.repost_reserved_qty #2015-08-17
|
||||
|
@ -6,7 +6,22 @@ import frappe
|
||||
from erpnext.utilities.repost_stock import update_bin_qty, get_reserved_qty
|
||||
|
||||
def execute():
|
||||
for item_code, warehouse in frappe.db.sql("select item_code, warehouse from tabBin where ifnull(reserved_qty, 0) < 0"):
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
||||
repost_for = frappe.db.sql("""
|
||||
select
|
||||
distinct item_code, warehouse
|
||||
from
|
||||
(
|
||||
(
|
||||
select distinct item_code, warehouse
|
||||
from `tabSales Order Item` where docstatus=1
|
||||
) UNION (
|
||||
select distinct item_code, warehouse
|
||||
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
|
||||
)
|
||||
) items
|
||||
""")
|
||||
|
||||
for item_code, warehouse in repost_for:
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.utilities.repost_stock import update_bin_qty, get_reserved_qty, repost_actual_qty
|
||||
from erpnext.utilities.repost_stock import repost_actual_qty
|
||||
|
||||
def execute():
|
||||
cancelled_invoices = frappe.db.sql_list("""select name from `tabSales Invoice`
|
||||
@ -19,10 +19,4 @@ def execute():
|
||||
% (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
|
||||
|
||||
for item_code, warehouse in repost_for:
|
||||
repost_actual_qty(item_code, warehouse)
|
||||
|
||||
for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
|
||||
from `tabPacked Item` where parenttype = 'Sales Invoice' and docstatus = 1"""):
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
||||
repost_actual_qty(item_code, warehouse)
|
Loading…
x
Reference in New Issue
Block a user