From 1d15c704afbc2c374ca5e4c39bae542aa2d09205 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Dec 2012 18:14:16 +0530 Subject: [PATCH] rejected serial no fixes --- buying/doctype/purchase_common/purchase_common.py | 7 +++---- stock/doctype/purchase_receipt/purchase_receipt.py | 3 ++- stock/doctype/stock_ledger/stock_ledger.py | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 566c01c0d5..eb8ebef874 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -353,10 +353,9 @@ class DocType(TransactionBase): raise Exception # validate stock item - if item[0][0]=='Yes': - if not d.warehouse: - msgprint("Warehouse is mandatory for %s, since it is a stock item" % d.item_code) - raise Exception + if item[0][0]=='Yes' and d.qty and not d.warehouse: + msgprint("Warehouse is mandatory for %s, since it is a stock item" % + d.item_code, raise_exception=1) # validate purchase item if item[0][1] != 'Yes' and item[0][2] != 'Yes': diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 3cf1f27566..04ad4dce07 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -230,7 +230,8 @@ class DocType(TransactionBase): get_obj("Warehouse", d.warehouse).update_bin(args) # UPDATE actual qty to warehouse by pr_qty - self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit) + if pr_qty: + self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit) # UPDATE actual to rejected warehouse by rejected qty if flt(d.rejected_qty) > 0: diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index b64abaf978..14166fc13a 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -80,14 +80,13 @@ class DocType: # [bug fix] need to strip serial nos of all spaces and new lines for validation serial_no = cstr(d.serial_no).strip() - if serial_no: if is_stock_item != 'Yes': msgprint("Serial No is not required for non-stock item: %s" % d.item_code, raise_exception=1) elif ar_required != 'Yes': msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + d.item_code + \ ', otherwise please remove serial no', raise_exception=1) - elif ar_required == 'Yes' and not serial_no: + elif ar_required == 'Yes' and not serial_no and d.qty: msgprint("Serial no is mandatory for item: "+ d.item_code, raise_exception = 1) # validate rejected serial nos