Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions export_bg/models/export_bg_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ def _prepare_export_data(self, data):
params = json.loads(data)
Model = self.env[params["model"]].with_context(**params.get("context", {}))
records = Model.browse(params["ids"]) if params.get("ids") else Model.search(params.get("domain", []))

# Support both 'name' and 'value' keys for field names (templates use 'name', regular exports use 'value')
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
field_labels = [f.get("label") or f.get("string") for f in params["fields"]]

return (
params,
[f["string"] for f in params["fields"]],
records.export_data([f["value"] for f in params["fields"]]).get("datas", []),
field_labels,
records.export_data(field_names).get("datas", []),
)

def web_export_csv(self, data):
Expand Down