[fix] Reserved qty is not calculating properly in BIN for multi sales UOM (#8203)
This commit is contained in:
parent
8519b4bfe4
commit
afa93c624b
@ -379,5 +379,5 @@ erpnext.patches.v7_2.rename_att_date_attendance
|
||||
erpnext.patches.v7_2.update_attendance_docstatus
|
||||
erpnext.patches.v7_2.move_dates_from_salary_structure_to_employee
|
||||
erpnext.patches.v7_2.make_all_assessment_group
|
||||
|
||||
erpnext.patches.v8_0.manufacturer_childtable_migrate
|
||||
erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom
|
@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.stock.stock_balance import update_bin_qty, get_reserved_qty
|
||||
|
||||
def execute():
|
||||
for doctype in ("Sales Order Item", "Bin"):
|
||||
frappe.reload_doctype(doctype)
|
||||
|
||||
repost_for = frappe.db.sql("""select distinct item_code, warehouse
|
||||
from `tabSales Order Item` where docstatus=1 and uom != stock_uom and
|
||||
exists(select name from tabItem where name=`tabSales Order Item`.item_code and ifnull(is_stock_item, 0)=1)""")
|
||||
|
||||
for item_code, warehouse in repost_for:
|
||||
update_bin_qty(item_code, warehouse, {
|
||||
"reserved_qty": get_reserved_qty(item_code, warehouse)
|
||||
})
|
@ -67,13 +67,13 @@ def get_balance_qty_from_sle(item_code, warehouse):
|
||||
def get_reserved_qty(item_code, warehouse):
|
||||
reserved_qty = frappe.db.sql("""
|
||||
select
|
||||
sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty))
|
||||
sum(dnpi_qty * ((so_item_qty - so_item_delivered_qty) / so_item_qty))
|
||||
from
|
||||
(
|
||||
(select
|
||||
qty as dnpi_qty,
|
||||
(
|
||||
select stock_qty from `tabSales Order Item`
|
||||
select qty from `tabSales Order Item`
|
||||
where name = dnpi.parent_detail_docname
|
||||
and (delivered_by_supplier is null or delivered_by_supplier = 0)
|
||||
) as so_item_qty,
|
||||
@ -94,7 +94,7 @@ def get_reserved_qty(item_code, warehouse):
|
||||
where name = dnpi_in.parent and docstatus = 1 and status != 'Closed')
|
||||
) dnpi)
|
||||
union
|
||||
(select qty as dnpi_qty, stock_qty as so_item_qty,
|
||||
(select stock_qty as dnpi_qty, qty as so_item_qty,
|
||||
delivered_qty as so_item_delivered_qty, parent, name
|
||||
from `tabSales Order Item` so_item
|
||||
where item_code = %s and warehouse = %s
|
||||
|
Loading…
x
Reference in New Issue
Block a user