first cut error fixes
diff --git a/patches/april_2012/repost_stock_for_posting_time.py b/patches/april_2012/repost_stock_for_posting_time.py
index 2249ac1..d9cbbe5 100644
--- a/patches/april_2012/repost_stock_for_posting_time.py
+++ b/patches/april_2012/repost_stock_for_posting_time.py
@@ -8,8 +8,6 @@
from stock.stock_ledger import update_entries_after
for d in res:
update_entries_after({
- item_code: d.item_code,
- warehouse: d.warehouse,
- posting_date: '2000-01-01',
- posting_time: '12:01'
+ "item_code": d.item_code,
+ "warehouse": d.warehouse,
})
diff --git a/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
index 10d4f50..81c6415 100644
--- a/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
+++ b/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
@@ -82,10 +82,10 @@
webnotes.conn.sql("update `tabStock Ledger Entry` set is_cancelled = 'Yes' where name = %s", d[3])
create_comment(d[3])
update_entries_after({
- item_code: d[0],
- warehouse: d[1],
- posting_date: "2012-07-01",
- posting_time: "12:05"
+ "item_code": d[0],
+ "warehouse": d[1],
+ "posting_date": "2012-07-01",
+ "posting_time": "12:05"
})
def create_comment(dn):
diff --git a/patches/september_2012/repost_stock.py b/patches/september_2012/repost_stock.py
index 1fec949..9720701 100644
--- a/patches/september_2012/repost_stock.py
+++ b/patches/september_2012/repost_stock.py
@@ -22,12 +22,7 @@
i=0
for d in res:
try:
- update_entries_after({
- item_code: d[0],
- warehouse: d[1],
- posting_date: "2000-01-01",
- posting_time: "12:00"
- })
+ update_entries_after({ "item_code": d[0], "warehouse": d[1] })
except:
pass
i += 1
diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py
index c9bd927..c473a6c 100644
--- a/stock/doctype/bin/bin.py
+++ b/stock/doctype/bin/bin.py
@@ -45,10 +45,10 @@
if args.get("actual_qty"):
# update valuation and qty after transaction for post dated entry
update_entries_after({
- item_code: self.doc.item_code,
- warehouse: self.doc.warehouse,
- posting_date: args.get("posting_date"),
- posting_time: args.get("posting_time")
+ "item_code": self.doc.item_code,
+ "warehouse": self.doc.warehouse,
+ "posting_date": args.get("posting_date"),
+ "posting_time": args.get("posting_time")
})
def update_qty(self, args):
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index ea44f1b..e3cafa2 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -157,14 +157,13 @@
"""get stock and incoming rate on posting date"""
for d in getlist(self.doclist, 'mtn_details'):
args = {
- item_code: d.item_code,
- warehouse: d.s_warehouse or d.t_warehouse,
- posting_date: self.doc.posting_date,
- posting_time: self.doc.posting_time,
- qty: d.transfer_qty,
- serial_no: d.serial_no,
- bom_no: d.bom_no
-
+ "item_code": d.item_code,
+ "warehouse": d.s_warehouse or d.t_warehouse,
+ "posting_date": self.doc.posting_date,
+ "posting_time": self.doc.posting_time,
+ "qty": d.transfer_qty,
+ "serial_no": d.serial_no,
+ "bom_no": d.bom_no
}
# get actual stock at source warehouse
d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0
@@ -308,8 +307,8 @@
import json
args, actual_qty, in_rate = json.loads(args), 0, 0
args.update({
- posting_date: self.doc.posting_date,
- posting_time: self.doc.posting_time
+ "posting_date": self.doc.posting_date,
+ "posting_time": self.doc.posting_time
})
ret = {
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
index b82a7f0..021a833 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -205,10 +205,10 @@
# repost future entries for selected item_code, warehouse
for entries in existing_entries:
update_entries_after({
- item_code: entries.item_code,
- warehouse: entries.warehouse,
- posting_date: self.doc.posting_date,
- posting_time: self.doc.posting_time
+ "item_code": entries.item_code,
+ "warehouse": entries.warehouse,
+ "posting_date": self.doc.posting_date,
+ "posting_time": self.doc.posting_time
})
diff --git a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
index 209bda5..9918010 100644
--- a/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
+++ b/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
@@ -91,7 +91,7 @@
if flt(self.doc.conversion_factor) != flt(1):
wh = sql("select name from `tabWarehouse`")
for w in wh:
- update_entries_after({item_code: self.doc.item_code, warehouse: w[0]})
+ update_entries_after({"item_code": self.doc.item_code, "warehouse": w[0]})
# acknowledge user
msgprint("Item Valuation Updated Successfully.")
diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py
index e65004b..775f0d0 100644
--- a/stock/doctype/warehouse/warehouse.py
+++ b/stock/doctype/warehouse/warehouse.py
@@ -121,12 +121,7 @@
if not warehouse:
warehouse = self.doc.name
- update_entries_after({
- item_code: item_code,
- warehouse: warehouse,
- posting_date: '1900-01-01',
- posting_time = '10:00'
- })
+ update_entries_after({ "item_code": item_code, "warehouse": warehouse })
def repost_reserved_qty(self, bin):
reserved_qty = webnotes.conn.sql("""
diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py
index d4475ef..bb02f8c 100644
--- a/stock/stock_ledger.py
+++ b/stock/stock_ledger.py
@@ -16,8 +16,9 @@
import webnotes
from webnotes import msgprint, _
-from webnotes.utils import cint
+from webnotes.utils import cint, flt, cstr
from stock.utils import _msgprint, get_valuation_method
+import json
# future reposting
@@ -67,7 +68,7 @@
qty_after_transaction += flt(sle.actual_qty)
# get stock value
- if serial_nos:
+ if sle.serial_nos:
stock_value = qty_after_transaction * valuation_rate
elif valuation_method == "Moving Average":
stock_value = (qty_after_transaction > 0) and \
@@ -101,7 +102,7 @@
entries between the cancelled entries in the same time-bucket
"""
sle = get_stock_ledger_entries(args,
- ["timestamp(posting_date, posting_time) < timestamp(%%(posting_date)s, %%(posting_time)s)"],
+ ["timestamp(posting_date, posting_time) < timestamp(%(posting_date)s, %(posting_time)s)"],
"limit 1")
return sle and sle[0] or webnotes._dict()
@@ -109,7 +110,7 @@
def get_sle_after_datetime(args):
"""get Stock Ledger Entries after a particular datetime, for reposting"""
return get_stock_ledger_entries(args,
- ["timestamp(posting_date, posting_time) > timestamp(%%(posting_date)s, %%(posting_time)s)"])
+ ["timestamp(posting_date, posting_time) > timestamp(%(posting_date)s, %(posting_time)s)"])
def get_stock_ledger_entries(args, conditions=None, limit=None):
"""get stock ledger entries filtered by specific posting datetime conditions"""
diff --git a/stock/utils.py b/stock/utils.py
index b3bf26a..2c0eaef 100644
--- a/stock/utils.py
+++ b/stock/utils.py
@@ -77,12 +77,11 @@
"sle": "name of reference Stock Ledger Entry"
}
"""
- if not args.get("posting_date"):
- args["posting_date"] = "1900-01-01"
- if not args.get("posting_time"):
- args["posting_time"] = "12:00"
+ if not args.get("posting_date"): args["posting_date"] = "1900-01-01"
+ if not args.get("posting_time"): args["posting_time"] = "12:00"
+ if not args.get("sle"): args["sle"] = ""
- sle = sql("""
+ sle = webnotes.conn.sql("""
select * from `tabStock Ledger Entry`
where item_code = %(item_code)s
and warehouse = %(warehouse)s