Merge pull request #1358 from nabinhait/hotfix
Serial no and planned qty
diff --git a/patches/1401/fix_planned_qty.py b/patches/1401/fix_planned_qty.py
new file mode 100644
index 0000000..96f56fb
--- /dev/null
+++ b/patches/1401/fix_planned_qty.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import webnotes
+
+def execute():
+ from utilities.repost_stock import repost_stock
+ for d in webnotes.conn.sql("""select distinct production_item, fg_warehouse
+ from `tabProduction Order` where docstatus>0""", as_dict=1):
+ repost_stock(d.production_item, d.fg_warehouse)
\ No newline at end of file
diff --git a/patches/1401/fix_serial_no_status_and_warehouse.py b/patches/1401/fix_serial_no_status_and_warehouse.py
new file mode 100644
index 0000000..fe43c28
--- /dev/null
+++ b/patches/1401/fix_serial_no_status_and_warehouse.py
@@ -0,0 +1,17 @@
+# 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 webnotes
+
+def execute():
+ serial_nos = webnotes.conn.sql("""select name from `tabSerial No` where docstatus=0
+ and status in ('Available', 'Sales Returned') and ifnull(warehouse, '') = ''""")
+ for sr in serial_nos:
+ try:
+ sr_bean = webnotes.bean("Serial No", sr[0])
+ sr_bean.make_controller().via_stock_ledger = True
+ sr_bean.save()
+ webnotes.conn.commit()
+ except:
+ pass
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 89e3309..3061720 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -267,4 +267,6 @@
"patches.1401.p01_make_buying_selling_as_check_box_in_price_list",
"patches.1401.update_billing_status_for_zero_value_order",
"patches.1401.enable_all_price_list",
+ "patches.1401.fix_serial_no_status_and_warehouse",
+ "patches.1401.fix_planned_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 bd2704d..e6557b4 100644
--- a/stock/doctype/serial_no/serial_no.py
+++ b/stock/doctype/serial_no/serial_no.py
@@ -87,6 +87,8 @@
self.doc.status = "Sales Returned"
else:
self.doc.status = "Available"
+ if not self.doc.warehouse:
+ self.doc.warehouse = last_sle.warehouse
else:
if document_type == "Purchase Return":
self.doc.status = "Purchase Returned"
@@ -94,6 +96,8 @@
self.doc.status = "Delivered"
else:
self.doc.status = "Not Available"
+ else:
+ self.doc.status = "Not Available"
def set_purchase_details(self, purchase_sle):
if purchase_sle:
@@ -185,10 +189,9 @@
def on_stock_ledger_entry(self):
if self.via_stock_ledger and not self.doc.fields.get("__islocal"):
last_sle = self.get_last_sle()
- if last_sle:
- self.set_status(last_sle.get("last_sle"))
- self.set_purchase_details(last_sle.get("purchase_sle"))
- self.set_sales_details(last_sle.get("delivery_sle"))
+ self.set_status(last_sle.get("last_sle"))
+ self.set_purchase_details(last_sle.get("purchase_sle"))
+ self.set_sales_details(last_sle.get("delivery_sle"))
def on_communication(self):
return
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 7dec878..c322a1a 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -346,7 +346,8 @@
pro_bean = webnotes.bean("Production Order", self.doc.production_order)
_validate_production_order(pro_bean)
self.update_produced_qty(pro_bean)
- self.update_planned_qty(pro_bean)
+ if self.doc.purpose == "Manufacture/Repack":
+ self.update_planned_qty(pro_bean)
def update_produced_qty(self, pro_bean):
if self.doc.purpose == "Manufacture/Repack":