Merge pull request #2134 from nabinhait/hotfix
Stock reconciliation fixes
diff --git a/erpnext/config/stock.py b/erpnext/config/stock.py
index afee0f5..bfb4b7f 100644
--- a/erpnext/config/stock.py
+++ b/erpnext/config/stock.py
@@ -74,8 +74,8 @@
},
{
"type": "doctype",
- "name": "Landed Cost Wizard",
- "description": _("Distribute transport overhead across items."),
+ "name": "Landed Cost Voucher",
+ "description": _("Update additional costs to calculate landed cost of items"),
},
{
"type": "doctype",
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
index f064198..682a16b 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
@@ -71,8 +71,9 @@
"read_only": 1
}
],
+ "icon": "icon-usd",
"is_submittable": 1,
- "modified": "2014-08-08 13:11:55.764550",
+ "modified": "2014-09-01 12:05:46.834513",
"modified_by": "Administrator",
"module": "Stock",
"name": "Landed Cost Voucher",
diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_records.json b/erpnext/stock/doctype/landed_cost_voucher/test_records.json
new file mode 100644
index 0000000..4fc0017
--- /dev/null
+++ b/erpnext/stock/doctype/landed_cost_voucher/test_records.json
@@ -0,0 +1,6 @@
+[
+ {
+ "doctype": "Landed Cost Voucher",
+ "name": "_Test Landed Cost Voucher 1"
+ }
+]
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 8b32211..40a980d 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -74,7 +74,7 @@
self.validation_messages.append(_get_msg(row_num, _("Warehouse not found in the system")))
# if both not specified
- if row[2] == "" and row[3] == "":
+ if row[2] in ["", None] and row[3] in ["", None]:
self.validation_messages.append(_get_msg(row_num,
_("Please specify either Quantity or Valuation Rate or both")))
@@ -149,13 +149,13 @@
})
# check valuation rate mandatory
- if row.qty != "" and not row.valuation_rate and \
+ if row.qty not in ["", None] and not row.valuation_rate and \
flt(previous_sle.get("qty_after_transaction")) <= 0:
frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
change_in_qty = row.qty not in ["", None] and \
(flt(row.qty) - flt(previous_sle.get("qty_after_transaction")))
-
+
change_in_rate = row.valuation_rate not in ["", None] and \
(flt(row.valuation_rate) - flt(previous_sle.get("valuation_rate")))
@@ -171,7 +171,7 @@
if previous_valuation_rate == 0:
return flt(valuation_rate)
else:
- if valuation_rate == "":
+ if valuation_rate in ["", None]:
valuation_rate = previous_valuation_rate
return (qty * valuation_rate - previous_qty * previous_valuation_rate) \
/ flt(qty - previous_qty)
@@ -179,8 +179,7 @@
if change_in_qty:
# if change in qty, irrespective of change in rate
incoming_rate = _get_incoming_rate(flt(row.qty), flt(row.valuation_rate),
- flt(previous_sle.get("qty_after_transaction")),
- flt(previous_sle.get("valuation_rate")))
+ flt(previous_sle.get("qty_after_transaction")), flt(previous_sle.get("valuation_rate")))
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
self.insert_entries({"actual_qty": change_in_qty, "incoming_rate": incoming_rate}, row)
@@ -211,7 +210,7 @@
def _insert_entries():
if previous_stock_queue != [[row.qty, row.valuation_rate]]:
# make entry as per attachment
- if row.qty:
+ if flt(row.qty):
row["voucher_detail_no"] = "Row: " + cstr(row.row_num) + "/Actual Entry"
self.insert_entries({"actual_qty": row.qty,
"incoming_rate": flt(row.valuation_rate)}, row)
@@ -225,7 +224,7 @@
if change_in_qty:
- if row.valuation_rate == "":
+ if row.valuation_rate in ["", None]:
# dont want change in valuation
if previous_stock_qty > 0:
# set valuation_rate as previous valuation_rate
diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py
index 1e1d5d9..4c14548 100644
--- a/erpnext/utilities/repost_stock.py
+++ b/erpnext/utilities/repost_stock.py
@@ -22,7 +22,7 @@
(select item_code, warehouse from tabBin
union
select item_code, warehouse from `tabStock Ledger Entry`) a"""):
- repost_stock(d[0], d[1], allow_negative_stock)
+ repost_stock(d[0], d[1])
if allow_negative_stock:
frappe.db.set_default("allow_negative_stock",
@@ -33,7 +33,7 @@
repost_actual_qty(item_code, warehouse)
if item_code and warehouse:
- update_bin(item_code, warehouse, {
+ update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse),
"indented_qty": get_indented_qty(item_code, warehouse),
"ordered_qty": get_ordered_qty(item_code, warehouse),
@@ -116,7 +116,7 @@
return flt(planned_qty[0][0]) if planned_qty else 0
-def update_bin(item_code, warehouse, qty_dict=None):
+def update_bin_qty(item_code, warehouse, qty_dict=None):
from erpnext.stock.utils import get_bin
bin = get_bin(item_code, warehouse)
mismatch = False
@@ -201,11 +201,11 @@
last_sle = sr.get_last_sle()
if flt(last_sle.actual_qty) > 0:
sr.warehouse = last_sle.warehouse
-
+
sr.via_stock_ledger = True
sr.save()
except:
pass
-
+
frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""")
-
+