@@ -565,7 +565,7 @@ def _process_external_id_fields(
565565 return converted_vals , external_id_fields
566566
567567
568- def _handle_create_error (
568+ def _handle_create_error ( # noqa: C901
569569 i : int ,
570570 create_error : Exception ,
571571 line : list [Any ],
@@ -978,36 +978,10 @@ def _execute_load_batch( # noqa: C901
978978 res = model .load (load_header , load_lines , context = context )
979979
980980 if res .get ("messages" ):
981- error = res ["messages" ][0 ].get ("message" , "Batch load failed." )
981+ res ["messages" ][0 ].get ("message" , "Batch load failed." )
982982 # Don't raise immediately, log and continue to capture in fail file
983- log .debug (
984- f"Expected records: { len (load_lines )} , "
985- f"Created records: { len (created_ids )} "
986- )
987-
988- # Always log detailed information about record creation
989- if len (created_ids ) != len (load_lines ):
990- log .warning (
991- f"Record creation mismatch: Expected { len (load_lines )} records, "
992- f"but only { len (created_ids )} were created"
993- )
994- if len (created_ids ) == 0 :
995- log .error (
996- f"No records were created in this batch of { len (load_lines )} . "
997- f"This may indicate silent failures in the Odoo load operation. "
998- f"Check Odoo server logs for validation errors."
999- )
1000- # Log the actual data being sent for debugging
1001- if load_lines :
1002- log .debug ("First few lines being sent:" )
1003- for i , line in enumerate (load_lines [:3 ]):
1004- log .debug (f" Line { i } : { dict (zip (load_header , line ))} " )
1005- else :
1006- log .warning (
1007- f"Partial record creation: { len (created_ids )} /{ len (load_lines )} "
1008- f"records were created. Some records may have failed validation."
1009- )
1010- # Check for any Odoo server errors in the response that should halt processing
983+ # Check for any Odoo server errors in the response that should halt
984+ # processing
1011985 if res .get ("messages" ):
1012986 for message in res ["messages" ]:
1013987 msg_type = message .get ("type" , "unknown" )
@@ -1023,7 +997,8 @@ def _execute_load_batch( # noqa: C901
1023997
1024998 created_ids = res .get ("ids" , [])
1025999 log .debug (
1026- f"Expected records: { len (load_lines )} , Created records: { len (created_ids )} "
1000+ f"Expected records: { len (load_lines )} , "
1001+ f"Created records: { len (created_ids )} "
10271002 )
10281003
10291004 # Always log detailed information about record creation
@@ -1035,8 +1010,8 @@ def _execute_load_batch( # noqa: C901
10351010 if len (created_ids ) == 0 :
10361011 log .error (
10371012 f"No records were created in this batch of { len (load_lines )} . "
1038- f"This may indicate silent failures in the Odoo load operation. "
1039- f"Check Odoo server logs for validation errors."
1013+ f"This may indicate silent failures in the Odoo load operation."
1014+ f" Check Odoo server logs for validation errors."
10401015 )
10411016 # Log the actual data being sent for debugging
10421017 if load_lines :
@@ -1045,14 +1020,16 @@ def _execute_load_batch( # noqa: C901
10451020 log .debug (f" Line { i } : { dict (zip (load_header , line ))} " )
10461021 else :
10471022 log .warning (
1048- f"Partial record creation: { len (created_ids )} /{ len (load_lines )} "
1049- f"records were created. Some records may have failed validation."
1023+ f"Partial record creation: { len (created_ids )} /{ len (load_lines )} "
1024+ f"records were created. "
1025+ f"Some records may have failed validation."
10501026 )
10511027
10521028 # Instead of raising an exception, capture failures for the fail file
10531029 # But still create what records we can
10541030 if res .get ("messages" ):
1055- # Extract error information and add to failed_lines to be written to fail file
1031+ # Extract error information and add to failed_lines to be written
1032+ # to fail file
10561033 error_msg = res ["messages" ][0 ].get ("message" , "Batch load failed." )
10571034 log .error (f"Capturing load failure for fail file: { error_msg } " )
10581035 # We'll add the failed lines to aggregated_failed_lines at the end
@@ -1094,13 +1071,19 @@ def _execute_load_batch( # noqa: C901
10941071 failed_line = [* list (line ), f"Load failed: { error_msg } " ]
10951072 aggregated_failed_lines .append (failed_line )
10961073
1097- # Create a new dictionary containing only the items with integer values
1074+ # Create a new dictionary containing only the items with
1075+ # integer values
10981076 filtered_id_map = {
10991077 key : value
11001078 for key , value in id_map .items ()
11011079 if isinstance (value , int )
11021080 }
1103- aggregated_id_map .update (filtered_id_map )
1081+ # Always update the aggregated map with successful records
1082+ # Create a new dictionary containing only the items with integer values
1083+ filtered_id_map = {
1084+ key : value for key , value in id_map .items () if isinstance (value , int )
1085+ }
1086+ aggregated_id_map .update (filtered_id_map )
11041087 lines_to_process = lines_to_process [chunk_size :]
11051088
11061089 # Reset serialization retry counter on successful processing
0 commit comments