Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index db6de44..0c11198 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -107,7 +107,7 @@
_(" does not belong to the company") + ": " + self.doc.company)
def check_negative_balance(account, adv_adj=False):
- if not adv_adj:
+ if not adv_adj and account:
account_details = webnotes.conn.get_value("Account", account,
["allow_negative_balance", "debit_or_credit"], as_dict=True)
if not account_details["allow_negative_balance"]:
diff --git a/patches/october_2013/p01_fix_serial_no_status.py b/patches/october_2013/p01_fix_serial_no_status.py
new file mode 100644
index 0000000..8700290
--- /dev/null
+++ b/patches/october_2013/p01_fix_serial_no_status.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import flt
+
+def execute():
+ serial_nos = webnotes.conn.sql("""select name, item_code, status from `tabSerial No`
+ where status!='Not in Use'""", as_dict=1)
+ for sr in serial_nos:
+ last_sle = webnotes.conn.sql("""select voucher_type, voucher_no, actual_qty
+ from `tabStock Ledger Entry` where serial_no like %s and item_code=%s
+ order by name desc limit 1""",
+ ("%%%s%%" % sr.name, sr.item_code), as_dict=1)
+
+ if flt(last_sle[0].actual_qty) > 0:
+ if last_sle[0].voucher_type == "Stock Entry" and webnotes.conn.get_value("Stock Entry",
+ last_sle[0].voucher_no, "purpose") == "Sales Return":
+ status = "Sales Returned"
+ else:
+ status = "Available"
+ else:
+ if last_sle[0].voucher_type == "Stock Entry":
+ purpose = webnotes.conn.get_value("Stock Entry", last_sle[0].voucher_no, "purpose")
+ if purpose == "Purchase Return":
+ status = "Purchase Returned"
+ else:
+ status = "Not Available"
+ else:
+ status = "Delivered"
+ if sr.status != status:
+ webnotes.conn.sql("""update `tabSerial No` set status=%s where name=%s""",
+ (status, sr.name))
+
+ webnotes.conn.sql("""update `tabSerial No` set warehouse=''
+ where status in ('Delivered', 'Purchase Returned')""")
+
+
+
\ No newline at end of file
diff --git a/selling/utils/__init__.py b/selling/utils/__init__.py
index 801d82b..6e74ac4 100644
--- a/selling/utils/__init__.py
+++ b/selling/utils/__init__.py
@@ -74,7 +74,7 @@
out.update(apply_pos_settings(pos_settings, out))
if args.doctype in ("Sales Invoice", "Delivery Note"):
- if item_bean.doc.has_serial_no and not args.serial_no:
+ if item_bean.doc.has_serial_no == "Yes" and not args.serial_no:
out.serial_no = _get_serial_nos_by_fifo(args, item_bean)
return out
diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 1c3d3e1..c29ca3a 100644
--- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -166,7 +166,7 @@
serial_nos.append(self.make_serial_no(make_autoname(item_det.serial_no_series)))
self.doc.serial_no = "\n".join(serial_nos)
else:
- webnotes.throw(_("Serial Number Required for Serialized Item" + ": " + self.doc.item),
+ webnotes.throw(_("Serial Number Required for Serialized Item" + ": " + self.doc.item_code),
SerialNoRequiredError)
def make_serial_no(self, serial_no):