File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -902,18 +902,22 @@ def _execute_load_batch( # noqa: C901
902902 "message" , "Batch load failed."
903903 )
904904 log .error (f"Capturing load failure for fail file: { error_msg } " )
905- # We'll add the failed lines to aggregated_failed_lines at the end
906-
907- # Use sanitized IDs for the id_map to match what was actually sent to Odoo
908- id_map = {
909- to_xmlid (line [uid_index ]): created_ids [i ]
910- if i < len (created_ids )
911- else None
912- for i , line in enumerate (current_chunk )
913- }
914-
915- # Remove None entries (failed creations) from id_map
916- id_map = {k : v for k , v in id_map .items () if v is not None }
905+ # We'll add the failed lines to aggregated_failed_lines
906+ # at the end
907+
908+ id_map = {}
909+ for i , line in enumerate (current_chunk ):
910+ # Ensure there's a corresponding created ID and that
911+ # it's a valid integer.
912+ # The 'incompatible type' error happens when the
913+ # value could be None.
914+ if i < len (created_ids ) and created_ids [i ] is not None :
915+ sanitized_id = to_xmlid (line [uid_index ])
916+ db_id = created_ids [i ]
917+ id_map [sanitized_id ] = db_id
918+
919+ # The update call remains the same and will now be type-safe.
920+ aggregated_id_map .update (id_map )
917921
918922 # Log id_map information for debugging
919923 log .debug (f"Created { len (id_map )} records in batch { batch_number } " )
You can’t perform that action at this time.
0 commit comments