Skip to content

Commit b0972c5

Browse files
author
bosd
committed
Add enhanced debugging for record creation verification\n\n- Add detailed error checking for model.load() responses\n- Log warnings/errors from Odoo load operations\n- Verify record creation counts and log mismatches\n- Add explicit logging when no records are created\n- Add id_map population debugging information\n\nThis will help identify why records aren't being created in Pass 1 despite\nthe load operation appearing to complete successfully.
1 parent 635e159 commit b0972c5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/odoo_data_flow/import_threaded.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,29 @@ def _execute_load_batch( # noqa: C901
701701
sanitized_load_lines.append(sanitized_line)
702702

703703
res = model.load(load_header, sanitized_load_lines, context=context)
704+
705+
# Check for any messages/warnings in the response that might indicate issues
706+
if res.get("messages"):
707+
for message in res["messages"]:
708+
msg_type = message.get("type", "unknown")
709+
msg_text = message.get("message", "")
710+
if msg_type in ["warning", "error"]:
711+
log.warning(f"Load operation returned {msg_type}: {msg_text}")
712+
else:
713+
log.info(f"Load operation returned {msg_type}: {msg_text}")
714+
715+
# Verify that the load operation actually created records
716+
created_ids = res.get("ids", [])
717+
if len(created_ids) != len(sanitized_load_lines):
718+
log.warning(
719+
f"Record creation mismatch: Expected {len(sanitized_load_lines)} records, "
720+
f"but only {len(created_ids)} were created"
721+
)
722+
if len(created_ids) == 0:
723+
log.error(
724+
"No records were created in this batch. This may indicate silent failures "
725+
"in the Odoo load operation. Check Odoo server logs for validation errors."
726+
)
704727
if res.get("messages"):
705728
error = res["messages"][0].get("message", "Batch load failed.")
706729
raise ValueError(error)
@@ -713,6 +736,13 @@ def _execute_load_batch( # noqa: C901
713736
id_map = {
714737
to_xmlid(line[uid_index]): created_ids[i] for i, line in enumerate(current_chunk)
715738
}
739+
740+
# Log id_map information for debugging
741+
log.debug(f"Created {len(id_map)} records in batch {batch_number}")
742+
if id_map:
743+
log.debug(f"Sample id_map entries: {dict(list(id_map.items())[:3])}")
744+
else:
745+
log.warning(f"No id_map entries created for batch {batch_number}")
716746
aggregated_id_map.update(id_map)
717747
lines_to_process = lines_to_process[chunk_size:]
718748

0 commit comments

Comments
 (0)