Enable report download and bulk upload on a view
Goal: Add CSV/PDF export and bulk CSV import to a list, form, or kanban with one line of XML — no Go code in your addon.
The report engine lives in sumeru/ only. Addons declare capabilities on views; core handles generation, staging, mapping, and import.
Form toolbar: On form views, Report appears next to Save (not on list landing pages unless the list view also declares report XML). Prefer enabling report on the form when users export a single record from detail view.
1. Add XML to the view
In your module’s view file under views/, add a child to the list or form view:
<view id="view_crm_lead_list" model="crm.lead" type="list">
<report download="csv,pdf" upload="bulk" pdf_sizes="a4,legal,letter"/>
<field name="name"/>
...
</view>
Live example: sumeru_addons/crm/views/crm_lead_list_views.xml.
Shorthand alternatives
View attributes:
<view type="list" model="my_module.my_model" report_download="csv,pdf" bulk_upload="1">
Header widgets (forms):
<header>
<widget type="report_download" formats="csv,pdf"/>
<widget type="bulk_upload" modes="create,upsert"/>
</header>
Full XML reference: Report engine.
2. Update the module
From your Sumeru install directory:
./sumeru -c sumeru.conf -u your_module
Restart the server if it is already running.
3. Verify in the workspace
- Sign in and open the menu action that uses your list view.
- Confirm Report appears in the toolbar.
- Test Download CSV with default columns.
- Test Download import template and Bulk upload (mapping form should open after upload).
4. Optional — custom export cell text
If a field needs special formatting in CSV/PDF (not in the UI), register a formatter in your addon init():
import "sumeru/core/sdk"
func init() {
sdk.RegisterReportCellFormatter("my_module.my_model", func(model, field string, raw interface{}) string {
if field == "state" {
// custom labels for export
}
return sdk.AsString(raw)
})
}
Do not add PDF libraries or custom /web/export/* routes in addons.
What not to do
| Avoid | Why |
|---|---|
Export/import Go code in sumeru_addons/ | Engine is core-only |
| Custom HTTP handlers for CSV/PDF | Use core routes |
| Copy mapping UI into your addon | Use sys.bulk.import wizard in base |
gofpdf or other PDF libs in addon go.mod | PDF generation is in core |