Skip to content

Commit d0710dc

Browse files
author
bosd
committed
Fix error handling in batch load response processing\n\n- Improve error handling for Odoo load response messages\n- Distinguish between fatal errors, warnings, and info messages\n- Only raise ValueError for actual 'error' type messages\n- Log warnings and info messages without halting processing\n- Add proper message iteration to handle multiple response messages\n- Provide detailed logging for each message type received\n- Ensure record creation debugging runs even when there are non-fatal messages\n\nThis fixes the issue where all messages (including warnings) were causing\nValueError exceptions that prevented proper debugging output and record creation verification.
1 parent 29ace86 commit d0710dc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/odoo_data_flow/import_threaded.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,19 @@ def _execute_load_batch( # noqa: C901
750750
f"Partial record creation: {len(created_ids)}/{len(sanitized_load_lines)} "
751751
f"records were created. Some records may have failed validation."
752752
)
753+
# Check for any Odoo server errors in the response that should halt processing
753754
if res.get("messages"):
754-
error = res["messages"][0].get("message", "Batch load failed.")
755-
raise ValueError(error)
755+
for message in res["messages"]:
756+
msg_type = message.get("type", "unknown")
757+
msg_text = message.get("message", "")
758+
if msg_type == "error":
759+
# Only raise for actual errors, not warnings
760+
log.error(f"Load operation returned fatal error: {msg_text}")
761+
raise ValueError(msg_text)
762+
elif msg_type in ["warning", "info"]:
763+
log.warning(f"Load operation returned {msg_type}: {msg_text}")
764+
else:
765+
log.info(f"Load operation returned {msg_type}: {msg_text}")
756766

757767
created_ids = res.get("ids", [])
758768
log.debug(f"Expected records: {len(sanitized_load_lines)}, Created records: {len(created_ids)}")

0 commit comments

Comments
 (0)