From d83e8c56b22ee73bfbcacd9ebf4ad06d2cce98cb Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 15 May 2019 14:10:10 +0530 Subject: [PATCH] fix: set barcode on selection of item if item has one barcode --- erpnext/stock/get_item_details.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index f9a4a151a4b..cb2c62e7b0a 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -306,8 +306,21 @@ def get_basic_details(args, item): for fieldname in ("item_name", "item_group", "barcodes", "brand", "stock_uom"): out[fieldname] = item.get(fieldname) + child_doctype = args.doctype + ' Item' + meta = frappe.get_meta(child_doctype) + if meta.get_field("barcode"): + update_barcode_value(out) + return out +def update_barcode_value(out): + from erpnext.accounts.doctype.sales_invoice.pos import get_barcode_data + barcode_data = get_barcode_data([out]) + + # If item has one barcode then update the value of the barcode field + if barcode_data and len(barcode_data.get(out.item_code)) == 1: + out['barcode'] = barcode_data.get(out.item_code) + @frappe.whitelist() def calculate_service_end_date(args, item=None): args = process_args(args)