odoo_stock_initial_import
Import opening stock balances via SQL INSERT, bypassing ORM overrides. Creates stock moves, lines, quants, and valuation layers with version-aware logic and UTC conversion. Use dry_run first.
Instructions
Import opening stock balances (initial inventory) via direct SQL INSERT, bypassing ORM overrides (e.g. custom modules that null out stock.move.name). Version-aware: v14-v18 creates stock.move + stock.move.line + stock.valuation.layer + stock.quant; v19 creates stock.move (with value/price_unit/remaining_qty/remaining_value/is_valued=true/is_in=true fields — SVL does not exist) + stock.move.line + stock.quant. All datetimes anchored at 23:59:59 in the caller's timezone, converted to UTC before INSERT. Writes a JSON snapshot to /backups// before execution. ALWAYS use dry_run=true first to preview the plan and catch category/location/product errors. For real_time valuation, follow up with odoo_stock_initial_opening_journal to book the account entry (SQL INSERT does NOT create account.move).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | default | |
| company_id | Yes | Target company for the opening balance | |
| accounting_date | Yes | YYYY-MM-DD — accounting date (usually last day of prior fiscal year, e.g. '2025-12-31') | |
| tz | Yes | IANA timezone of the caller (e.g. 'Europe/Sofia', 'UTC'). 23:59:59 in this tz is converted to UTC for INSERT. | |
| items | Yes | Opening balance rows. One entry per (product, location, lot). | |
| reference_prefix | No | Prefix for stock.move name/reference. Final form: '<prefix> [Accounted on YYYY-MM-DD]'. | Product Quantity Updated |
| dry_run | No | If true, only preview + pre-flight checks. Set false to execute. |