| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 609 |
| Technical Name |
import_core |
| License | AGPL-3 |
| Website | https://github.com/tawasta/server-tools |
Import Core
Generic CSV/XLSX import core for Odoo 17.
This module provides a flexible import framework with:
- Configurable import templates
- Ordered import step pipelines
- CSV and XLSX support
- Dynamic field mappings
- Shared import state between steps
- Create/write state link handling
- Pluggable runner modules
The module itself does not implement business imports directly. Business logic is provided by separate step modules.
Features
Import templates
Templates define:
- Import step execution order
- CSV/XLSX column mappings
- Search fields for matching existing records
- State link relations between imported records
Import steps
Each import step is registered as:
- generic.import.step
and dispatched dynamically to:
- generic.import.runner.<code>
Example:
- Step code: partner
- Runner model: generic.import.runner.partner
If the runner model is not installed, the step is skipped automatically.
Steps may also declare required models:
required_models = "res.partner,sale.order"
Unavailable model dependencies automatically disable the step.
Supported file formats
CSV
- UTF-8 with BOM supported
- Latin-1 fallback supported
XLSX
Implemented using:
- openpyxl
The first worksheet is imported automatically.
Configuration
Install import_core and one or more step modules.
Example:
- import_step_contacts
After installation:
- Go to: Imports -> Templates
- Create a new template
- Add import steps
- Configure field mappings
- Configure optional state links
Import steps
Templates use template-specific step ordering.
This means:
- Global step sequence does not affect template execution order
- Each template controls its own pipeline independently
Field mappings
Each mapping line defines:
- CSV/XLSX column name
- Target model
- Target field
- Whether the field is used for record matching
Search fields are used to build lookup domains before creating records.
Example:
- email may be marked as a search field for res.partner
Allowed models are automatically restricted based on selected import steps.
State links
State links allow imported records to reference previously created records.
Two modes are supported:
Create
Applied before record creation.
Used for required many2one fields that must exist during create().
Write
Applied after step execution using write().
Useful when records must exist before linking.
Example flow:
- Partner step creates res.partner
- Sale order step creates sale.order
- State link writes:
- sale.order.partner_id -> state["partner"]
Usage
Create / edit templates
- Open: Imports -> Templates
- Create a template
- Add import steps
- Configure field mappings
- Configure optional state links
Run an import
- Open: Imports -> Templates -> Import (Upload)
- Select the template
- Download the CSV template if needed
- Upload CSV or XLSX file
- Click Upload
Import processing
The import wizard:
- Reads the uploaded file
- Converts rows into model-specific values
- Executes import steps sequentially
- Passes shared state between steps
- Applies state links
Runner helpers
generic.import.runner.base provides reusable helpers:
- _get_or_create()
- _get_or_create_from_lines()
- _build_domain()
- _clean_vals()
- _set_state_record()
These helpers simplify custom runner implementations.
Example runner
from odoo import models class ImportPartner(models.AbstractModel): _name = "generic.import.runner.partner" _inherit = "generic.import.runner.base" def run(self, row_index, row, lines_by_model, state): partner = self._get_or_create_from_lines( "res.partner", lines_by_model, row_index, row, state=state, ) return self._set_state_record( state, "partner", partner, )
Security
Access rights are included for:
- Import templates
- Template lines
- Template state links
- Template steps
- File upload wizard
Import step definitions are read-only for normal users.
Technical notes
Step execution is skipped automatically when:
- Required Odoo models are unavailable
- Runner implementations are missing
This allows optional business modules to extend the framework safely.
Dependencies
Python dependencies:
- openpyxl
Known issues / Roadmap
Credits
Contributors
- Valtteri Lattu <valtteri.lattu@tawasta.fi>
Maintainer
This module is maintained by Oy Tawasta OS Technologies Ltd.
Please log in to comment on this module