From 14bd43d5eb9420b8860b87c8715d9f9524a89694 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 27 Apr 2018 16:24:05 +0530 Subject: [PATCH] minor changes --- erpnext/controllers/accounts_controller.py | 1 - erpnext/public/js/controllers/transaction.js | 1 - erpnext/public/js/utils.js | 2 +- erpnext/stock/get_item_details.py | 18 ++++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index c70cfcd8111..31a3f6c5a53 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -198,7 +198,6 @@ class AccountsController(TransactionBase): if self.get("is_subcontracted"): args["is_subcontracted"] = self.is_subcontracted - ret = get_item_details(args) for fieldname, value in ret.items(): diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3da28a88cf2..102090b812d 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -304,7 +304,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ this.frm.doc.doctype === 'Delivery Note') { show_batch_dialog = 1; } - // clear barcode if setting item (else barcode will take priority) if(!from_barcode) { item.barcode = null; diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 0e6017987a1..a9ac8c4e619 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -69,7 +69,7 @@ $.extend(erpnext, { "get_query": function () { return { filters: { - item_code:grid_row.doc.item_code , + item_code:grid_row.doc.item_code, warehouse:cur_frm.doc.is_return ? null : grid_row.doc.warehouse } } diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index e3617111bc5..bcef4727859 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -76,7 +76,6 @@ def get_item_details(args): args[key] = value out.update(get_pricing_rule_for_item(args)) - if (args.get("doctype") == "Delivery Note" or (args.get("doctype") == "Sales Invoice" and args.get('update_stock'))) \ and out.warehouse and out.stock_qty > 0: @@ -86,8 +85,12 @@ def get_item_details(args): actual_batch_qty = get_batch_qty(out.batch_no, out.warehouse, out.item_code) if actual_batch_qty: out.update(actual_batch_qty) - - if out.has_serial_no: + + if out.has_serial_no and args.get('batch_no'): + out.batch_no = args.get('batch_no') + out.serial_no = get_serial_no(out, args.serial_no) + + elif out.has_serial_no: out.serial_no = get_serial_no(out, args.serial_no) if args.transaction_date and item.lead_time_days: @@ -468,7 +471,7 @@ def get_serial_nos_by_fifo(args): def get_serial_no_batchwise(args): if frappe.db.get_single_value("Stock Settings", "automatically_set_serial_nos_based_on_fifo"): return "\n".join(frappe.db.sql_list("""select name from `tabSerial No` - where item_code=%(item_code)s and warehouse=%(warehouse)s and batch_no=%(batch_no)s + where item_code=%(item_code)s and warehouse=%(warehouse)s and (batch_no=%(batch_no)s or batch_no is NULL) order by timestamp(purchase_date, purchase_time) asc limit %(qty)s""", { "item_code": args.item_code, "warehouse": args.warehouse, @@ -688,14 +691,13 @@ def get_serial_no(args, serial_nos=None): if args.get('warehouse') and args.get('stock_qty') and args.get('item_code'): has_serial_no = frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") - if args.get('batch_no') and has_serial_no == 1: return get_serial_no_batchwise(args) - # elif (args.get('has_batch_no') == 1) and has_serial_no == 1 and not args.get(batch_no): + # elif (args.get('has_batch_no') == 1) and has_serial_no == 1 and not args.get('batch_no'): # args.batch_no = get_batch_no(args.item_code, args.warehouse, args.qty) - # actual_batch_qty = get_batch_qty(out.batch_no, out.warehouse, out.item_code) + # actual_batch_qty = get_batch_qty(args.batch_no, args.warehouse, args.item_code) # if actual_batch_qty: - # out.update(actual_batch_qty) + # args.update(actual_batch_qty) # return get_serial_no_batchwise(args) elif has_serial_no == 1: args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"stock_qty": args.get('stock_qty')})