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)