Skip to content

Commit 6b4b4ea

Browse files
committed
[FIX] export_bg: Handle import_compat parameter correctly in background export
When import_compat=False, avoid using field 'value' for data extraction to prevent issues when the exported data is used for record updates. - In import_compat mode: use name -> value -> id fallback chain - In regular export mode: use only name -> id (skip 'value') - Field labels (headers) are handled appropriately for each mode This ensures exported data maintains proper field references based on the intended use case (import vs display/update). closes #367 Signed-off-by: Franco Leyes <lef@adhoc.com.ar>
1 parent 69042b2 commit 6b4b4ea

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

export_bg/models/export_bg_mixin.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ def _export_chunk_bg(self, data, export_id, export_format):
3939
]
4040
)
4141

42-
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
43-
field_labels = [f.get("label") or f.get("string") for f in params["fields"]]
42+
# Extract field names considering import_compat mode
43+
import_compat = params.get("import_compat", True)
44+
45+
# For field_names (data extraction), always use the technical field name
46+
# Only use 'value' as fallback when import_compat=True (for import compatibility)
47+
if import_compat:
48+
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
49+
field_labels = field_names # Use field names as headers for import compatibility
50+
else:
51+
# When not import_compat, use only 'name' or 'id' for field_names, not 'value'
52+
field_names = [f.get("name") or f.get("id") for f in params["fields"]]
53+
field_labels = [f.get("label") or f.get("string") for f in params["fields"]]
4454

4555
export_data = self.export_data(field_names).get("datas", [])
4656

0 commit comments

Comments
 (0)