| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Contacts (contacts)
• Discuss (mail) • Invoicing (account) |
| Community Apps Dependencies | Show |
| Lines of code | 747 |
| Technical Name |
import_step_sale |
| License | AGPL-3 |
| Website | https://github.com/tawasta/server-tools |
Import Step: Sales
Adds a Sales Orders + Lines import step for the import_core framework.
This module registers:
- Import step: sale
- Runner model: generic.import.runner.sale
The step integrates with the generic dispatcher provided by import_core.
Features
The sales import step supports:
- Creating sales orders
- Reusing existing sales orders via search fields
- Creating sales order lines
- Reusing existing sales order lines via search fields
- Shared import state integration
- Automatic order-line linking
- Integration with imported contacts and products
- Sequential import chaining
The module depends on:
- import_core
- sale
- import_step_contacts
- import_step_products
Import step registration
The module registers the following import step:
<record id="generic_import_step_sale" model="generic.import.step"> <field name="name">Sales Orders + Lines</field> <field name="code">sale</field> <field name="sequence">40</field> <field name="required_models"> sale.order,sale.order.line </field> </record>
This means:
The dispatcher executes runner:
generic.import.runner.sale
The step is only available when models:
- sale.order
- sale.order.line
are installed.
Configuration
Install modules:
- import_core
- sale
- import_step_contacts
- import_step_products
- import_step_sale
Open:
Imports -> Templates
Create or edit a template
Add import step:
- Sales Orders + Lines
Configure field mappings for models:
- sale.order
- sale.order.line
Optionally mark fields as:
- Is search field
Search fields are used to find existing records before creating new ones.
Usage
Sales order import
Map CSV/XLSX columns to sale.order fields.
Example mappings:
- Order Reference -> sale.order.client_order_ref
- Order Date -> sale.order.date_order
Import behavior:
- Existing sales orders are reused when search fields match
- New sales orders are created when no match exists
Example CSV
Customer,Product,Quantity Example Customer,Test Product,2
Sales order line import
Map CSV/XLSX columns to sale.order.line fields.
Example mappings:
- Quantity -> sale.order.line.product_uom_qty
- Price -> sale.order.line.price_unit
Import behavior:
- Existing sales order lines are reused when search fields match
- New sales order lines are created when no match exists
Automatic linking
The runner automatically stores created records into shared state.
Sales order:
state = self._set_state_record( state, "sale_order", sale_order, )
Sales order line:
state = self._set_state_record( state, "sale_order_line", sale_order_line, )
This allows state links to assign relations automatically.
Typical state link examples:
Partner to sales order
source_state_key = partner target_model = sale.order target_field = partner_id
Product to sales order line
source_state_key = product target_model = sale.order.line target_field = product_id
Sales order to sales order line
source_state_key = sale_order target_model = sale.order.line target_field = order_id
Technical implementation
The runner inherits:
_inherit = "generic.import.runner.base"
Available helper methods include:
- _get_or_create()
- _get_or_create_from_lines()
- _build_domain()
- _clean_vals()
- _set_state_record()
Import flow
Simplified processing order:
- Read mapped sales order values
- Search/create sale.order
- Store order into shared state
- Read mapped sales line values
- Search/create sale.order.line
- Store line into shared state
- Apply configured state links
Search field behavior
Fields marked as Is search field are used to build lookup domains.
Example:
- client_order_ref marked as search field
The runner performs:
self.env["sale.order"].search([ ("client_order_ref", "=", value) ], limit=1)
If a matching record is found:
- Existing record is reused
- Duplicate creation is avoided
Dependencies
Python dependencies:
- None
Odoo dependencies:
- import_core
- sale
- import_step_contacts
- import_step_products
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