[production] update planned and produced ty

This commit is contained in:
Nabin Hait
2013-10-11 18:31:33 +05:30
parent 93c836c86d
commit eea2b34f4b
10 changed files with 268 additions and 207 deletions

View File

@@ -3,19 +3,9 @@
def execute():
import webnotes
from webnotes.utils import flt
for d in webnotes.conn.sql("select name, item_code, warehouse, ordered_qty from tabBin",
as_dict=1):
ordered_qty = webnotes.conn.sql("""
select sum((po_item.qty - po_item.received_qty)*po_item.conversion_factor)
from `tabPurchase Order Item` po_item, `tabPurchase Order` po
where po_item.item_code=%s and po_item.warehouse=%s
and po_item.qty > po_item.received_qty and po_item.parent=po.name
and po.status!='Stopped' and po.docstatus=1""", (d.item_code, d.warehouse))
from utilities.repost_stock import get_ordered_qty, update_bin
if flt(d.ordered_qty) != flt(ordered_qty[0][0]):
webnotes.conn.set_value("Bin", d.name, "ordered_qty", flt(ordered_qty[0][0]))
webnotes.conn.sql("""update tabBin set projected_qty = actual_qty + planned_qty +
indented_qty + ordered_qty - reserved_qty where name = %s""", d.name)
for d in webnotes.conn.sql("select item_code, warehouse from tabBin"):
update_bin(d[0], d[1], {
"ordered_qty": get_ordered_qty(d[0], d[1])
})