From 4b15e692f14f8da80fb3f600dd88592cf537cc90 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Oct 2024 12:41:39 +0200 Subject: [PATCH] fix: guard against undeclared columns --- erpnext/edi/doctype/code_list/code_list_import.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/edi/doctype/code_list/code_list_import.py b/erpnext/edi/doctype/code_list/code_list_import.py index 297b9a76db4a..98ff87993c0a 100644 --- a/erpnext/edi/doctype/code_list/code_list_import.py +++ b/erpnext/edi/doctype/code_list/code_list_import.py @@ -80,6 +80,12 @@ def get_columns_and_examples(file_path): for row in root.findall(".//SimpleCodeList/Row"): for value in row.findall("Value"): column_id = value.get("ColumnRef") + if column_id not in columns: + # Handle undeclared column + columns.append(column_id) + example_values[column_id] = [] + filterable_columns[column_id] = set() + value_text = value.find("./SimpleValue").text filterable_columns[column_id].add(value_text)