@@ -602,7 +602,7 @@ def _handle_create_error( # noqa: C901
602602 or "too many connections" in error_str_lower
603603 or "poolerror" in error_str_lower
604604 ):
605- error_message = (
605+ error_message = (
606606 f"Database connection pool exhaustion in row { i + 1 } : { create_error } "
607607 )
608608 if "Fell back to create" in error_summary :
@@ -1053,7 +1053,8 @@ def _execute_load_batch( # noqa: C901
10531053 # to fail file
10541054 error_msg = res ["messages" ][0 ].get ("message" , "Batch load failed." )
10551055 log .error (f"Capturing load failure for fail file: { error_msg } " )
1056- # Add all current chunk records to failed lines since there are error messages
1056+ # Add all current chunk records to failed lines since there are
1057+ # error messages
10571058 for line in current_chunk :
10581059 failed_line = [* line , f"Load failed: { error_msg } " ]
10591060 aggregated_failed_lines .append (failed_line )
@@ -1080,19 +1081,25 @@ def _execute_load_batch( # noqa: C901
10801081 successful_count = len (created_ids )
10811082 total_count = len (load_lines )
10821083
1083- # If there are error messages from Odoo, all records in chunk should be marked as failed
1084+ # If there are error messages from Odoo, all records in chunk
1085+ # should be marked as failed
10841086 if res .get ("messages" ):
1085- # All records in the chunk are considered failed due to error messages
1086- successful_count = len (created_ids )
1087- total_count = len (load_lines )
1087+ # All records in the chunk are considered failed due to
1088+ # error messages
1089+ successful_count = len (created_ids )
1090+ total_count = len (load_lines )
10881091
1089- # If there are error messages from Odoo, all records in chunk should be marked as failed
1092+ # If there are error messages from Odoo, all records in chunk should
1093+ # be marked as failed
10901094 if res .get ("messages" ):
1091- # All records in the chunk are considered failed due to error messages
1095+ # All records in the chunk are considered failed due to
1096+ # error messages
10921097 log .info (
1093- f"All { len (current_chunk )} records in chunk marked as failed due to error messages"
1098+ f"All { len (current_chunk )} records in chunk marked as "
1099+ f"failed due to error messages"
10941100 )
1095- # Don't add them again since they were already added in the earlier block
1101+ # Don't add them again since they were already added in the
1102+ # earlier block
10961103 elif successful_count < total_count :
10971104 failed_count = total_count - successful_count
10981105 log .info (f"Capturing { failed_count } failed records for fail file" )
@@ -1198,7 +1205,8 @@ def _execute_load_batch( # noqa: C901
11981205 continue
11991206
12001207 # For all other exceptions, use the original scalable error detection
1201- # Also check for constraint violations which should be treated as non-scalable
1208+ # Also check for constraint violations which should be treated as
1209+ # non-scalable
12021210 is_constraint_violation = (
12031211 "constraint" in error_str
12041212 or "violation" in error_str
@@ -1219,9 +1227,11 @@ def _execute_load_batch( # noqa: C901
12191227 or "poolerror" in error_str .lower ()
12201228 )
12211229
1222- # Handle constraint violations separately - these are data issues, not scalable issues
1230+ # Handle constraint violations separately - these are data issues,
1231+ # not scalable issues
12231232 if is_constraint_violation :
1224- # Constraint violations are data problems, add all records to failed lines
1233+ # Constraint violations are data problems, add all records to
1234+ # failed lines
12251235 clean_error = str (e ).strip ().replace ("\\ n" , " " )
12261236 log .error (
12271237 f"Constraint violation in batch { batch_number } : { clean_error } "
0 commit comments