| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Contacts (contacts)
• Discuss (mail) |
| Community Apps Dependencies | Show |
| Lines of code | 669 |
| Technical Name |
import_step_contacts |
| License | AGPL-3 |
| Website | https://github.com/tawasta/server-tools |
Import Step: Contacts
Adds a Partners import step for the import_core framework.
This module registers:
- Import step: partner
- Runner model: generic.import.runner.partner
The step integrates with the generic dispatcher provided by import_core.
Features
The partner import step supports:
- Creating new partners
- Reusing existing partners via search fields
- Parent/child contact imports
- Shared import state integration
- Automatic child contact linking
- Sequential import chaining
The module depends on:
- import_core
- contacts
Import step registration
The module registers the following import step:
<record id="generic_import_step_partner" model="generic.import.step"> <field name="name">Partners</field> <field name="code">partner</field> <field name="sequence">10</field> <field name="required_models">res.partner</field> </record>
This means:
The dispatcher executes runner:
generic.import.runner.partner
The step is only available when model res.partner exists.
Configuration
Install modules:
- import_core
- contacts
- import_step_contacts
Open:
Imports -> Templates
Create or edit a template
Add import step:
- Partners
Configure field mappings for:
- res.partner
Optionally mark fields as:
- Is search field
Search fields are used to find existing partners before creating new ones.
Usage
Basic partner import
Map CSV/XLSX columns to res.partner fields.
Example mappings:
- Name -> res.partner.name
- Email -> res.partner.email
- Phone -> res.partner.phone
Import behavior:
- Existing partners are reused when search fields match
- New partners are created when no match exists
- name is required for new partner creation
Example CSV
Name,Email,Phone Test Partner,test@example.com,123456
Search field behavior
Fields marked as Is search field are used to build search domains.
Example:
- email marked as search field
The runner performs:
self.env["res.partner"].search([ ("email", "=", value) ], limit=1)
If a record is found:
- Existing record is reused
- Duplicate creation is avoided
Child contacts
Child contacts are supported using CSV/XLSX column:
- Tyyppi
If value equals:
- child
(case-insensitive)
then the row is treated as a child contact.
Example CSV
Tyyppi,Name,Email main,Company A,company@example.com child,John Doe,john@example.com child,Jane Doe,jane@example.com
Behavior
When importing child rows:
The latest main partner is stored in shared state
Child contacts automatically receive:
parent_id = main_partner.id
Child rows skip remaining import steps using:
state["_skip_rest"] = True
This prevents child contact rows from executing unrelated import logic.
Error handling
The module provides user-friendly validation errors.
Missing main partner
If a child row appears before a main partner:
Child-kontaktirivi ilman pääkontaktia.
Missing partner name
If a new partner would be created without name:
Partnerilta puuttuu nimi (name).
Errors include:
- CSV row number
- Original row data
- Processed values
Technical implementation
The runner inherits:
_inherit = "generic.import.runner.base"
Available helper methods include:
- _get_or_create()
- _clean_vals()
- _set_state_record()
- _build_domain()
Partner creation flow
Simplified flow:
- Read mapped values
- Build search domain
- Search existing partner
- Create if not found
- Store result into shared state
- Handle child logic
Dependencies
Python dependencies:
- None
Odoo dependencies:
- import_core
- contacts
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