From fb0274b2495b26e8a18e65e64705a05c8e939065 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 5 Oct 2013 14:56:53 +0530 Subject: [PATCH 1/4] [patch] [minor] fix serial no status --- .../october_2013/p01_fix_serial_no_status.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 patches/october_2013/p01_fix_serial_no_status.py 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 0000000000..8700290fcd --- /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 From 0352f9b8270de20684bb70700f85d40e4289a056 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 5 Oct 2013 15:38:43 +0530 Subject: [PATCH 2/4] [fix] [minor] gl entry cancellation --- accounts/doctype/gl_entry/gl_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py index db6de44f09..0c11198be9 100644 --- a/accounts/doctype/gl_entry/gl_entry.py +++ b/accounts/doctype/gl_entry/gl_entry.py @@ -107,7 +107,7 @@ class DocType: _(" 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"]: From 704a915feb29e80377d0adbbb617ca9746bff031 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 5 Oct 2013 17:20:23 +0530 Subject: [PATCH 3/4] [fix] [minor] [delivery note] --- selling/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selling/utils/__init__.py b/selling/utils/__init__.py index 801d82bf40..6e74ac4869 100644 --- a/selling/utils/__init__.py +++ b/selling/utils/__init__.py @@ -74,7 +74,7 @@ def get_item_details(args): 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 From 842e9d60cc8118bef78c4e57a6040f69c149989f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 5 Oct 2013 19:57:39 +0530 Subject: [PATCH 4/4] [fix] [minor] serial no update --- stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 1c3d3e132d..c29ca3a173 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 @@ class DocType(DocListController): 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):