[fix] [minor] repost order qty patch
diff --git a/patches/december_2012/repost_ordered_qty.py b/patches/december_2012/repost_ordered_qty.py
index 2e3c690..e73b726 100644
--- a/patches/december_2012/repost_ordered_qty.py
+++ b/patches/december_2012/repost_ordered_qty.py
@@ -4,15 +4,18 @@
def execute():
import webnotes
from webnotes.utils import flt
- bins = webnotes.conn.sql("select item_code, warehouse, name, ordered_qty from `tabBin`")
- for d in bins:
- ordered_qty = webnotes.conn.sql("""
- select sum(ifnull(po_item.qty, 0) - ifnull(po_item.received_qty, 0))
- from `tabPurchase Order Item` po_item, `tabPurchase Order` po
- where po_item.parent = po.name and po.docstatus = 1 and po.status != 'Stopped'
- and po_item.item_code = %s and po_item.warehouse = %s
- """, (d[0], d[1]))
- if flt(d[3]) != flt(ordered_qty[0][0]):
- webnotes.conn.sql("""update `tabBin` set ordered_qty = %s where name = %s""",
- (ordered_qty and ordered_qty[0][0] or 0, d[2]))
\ No newline at end of file
+ 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))
+
+ 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)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index f228acf..6a5d0f4 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -220,4 +220,5 @@
"patches.september_2013.p04_unsubmit_serial_nos",
"patches.september_2013.p05_fix_customer_in_pos",
"patches.october_2013.fix_is_cancelled_in_sle",
+ "patches.october_2013.repost_ordered_qty",
]
\ No newline at end of file
diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py
index 3922878..d806287 100644
--- a/stock/doctype/serial_no/serial_no.py
+++ b/stock/doctype/serial_no/serial_no.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cint, getdate, nowdate, cstr, flt, add_days
+from webnotes.utils import cint, getdate, cstr, flt, add_days
import datetime
from webnotes import msgprint, _, ValidationError
diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 8fef889..bfb0f0a 100644
--- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -3,8 +3,8 @@
from __future__ import unicode_literals
import webnotes
-from webnotes import _, msgprint
-from webnotes.utils import cint, flt, getdate, cstr
+from webnotes import msgprint
+from webnotes.utils import flt, getdate
from webnotes.model.controller import DocListController
class DocType(DocListController):
@@ -52,7 +52,7 @@
<b>%(item_code)s</b> at Warehouse <b>%(warehouse)s</b> \
as on %(posting_date)s %(posting_time)s""" % self.doc.fields)
- sself.doc.fields.pop('batch_bal')
+ self.doc.fields.pop('batch_bal')
def validate_mandatory(self):
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']