Skip to content

Commit 635e159

Browse files
author
bosd
committed
Fix O2M field name handling for /id suffixed columns\n\n- Handle both direct field names and /id suffixed field names in O2M tuple imports\n- Check if field exists and fall back to /id suffixed version when needed\n- Prevent ColumnNotFoundError when looking for variant_seller_ids vs variant_seller_ids/id\n- Add proper error logging with available columns for debugging\n\nThis fixes the ColumnNotFoundError that was preventing O2M tuple imports from completing.
1 parent 5a6fbd0 commit 635e159

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/odoo_data_flow/lib/relational_import.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,22 @@ def run_write_o2m_tuple_import(
696696
failed_records_to_report = []
697697

698698
# Filter for rows that actually have data in the o2m field
699-
o2m_df = source_df.filter(pl.col(field).is_not_null())
699+
# Handle both direct field names and /id suffixed field names
700+
actual_field = field
701+
if field not in source_df.columns:
702+
# Check if the field with /id suffix exists (common for relation fields)
703+
field_with_id = f"{field}/id"
704+
if field_with_id in source_df.columns:
705+
log.debug(f"Using field '{field_with_id}' instead of '{field}' for O2M filtering")
706+
actual_field = field_with_id
707+
else:
708+
log.error(
709+
f"Field '{field}' not found in source DataFrame. "
710+
f"Available columns: {list(source_df.columns)}"
711+
)
712+
return False
713+
714+
o2m_df = source_df.filter(pl.col(actual_field).is_not_null())
700715

701716
for record in o2m_df.iter_rows(named=True):
702717
parent_external_id = record["id"]

0 commit comments

Comments
 (0)