odoo_utility_scripts/README_IMPORT.md

2.4 KiB

Fixed Asset Import Tools

This folder contains scripts to manage the import and lifecycle of fixed assets in Odoo 17.

1. Import Script (import_fixed_assets.py)

Imports assets from an Excel file, handling depreciation calculation and creating the assets in "Running" state to avoid opening balance duplication.

Features

  • Avoids Double Posting: Sets assets to 'Running' manually.
  • Asset Code: Maps Column B ("Kode Barang") to asset_code.
  • Historical Cleanup: Deletes draft moves <= Cutoff Date to keep the books clean.
  • Auto-Model: Creates missing asset models (e.g. "PERALATAN DAPUR") on the fly.

Usage

Run the script providing the path to odoo-bin, odoo.conf, the Excel file, and the database name:

/path/to/venv/bin/python scripts/import_fixed_assets.py \
    <path_to_odoo_bin> \
    <path_to_odoo_conf> \
    <path_to_excel_file> \
    <database_name>

Example:

/home/suherdy/Pythoncode/odoo17/.venv/bin/python scripts/import_fixed_assets.py \
    /home/suherdy/Pythoncode/odoo17/odoo/odoo-bin \
    /home/suherdy/Pythoncode/odoo17/odoo.conf \
    "/home/suherdy/Pythoncode/odoo17/Fixed Asset Kipas.xlsx" \
    kipasdbclone5

2. Post Depreciation (post_depreciation.py)

Posts all Draft depreciation entries found in the system up to a specific date (default: today). This is useful to "catch up" depreciation for Nov/Dec 2025 after import.

Usage

/home/suherdy/Pythoncode/odoo17/.venv/bin/python scripts/post_depreciation.py

Note: You may need to edit the POST_UP_TO_DATE variable inside the script to target a specific date.


3. Delete All Assets (delete_all_assets.py)

⚠ WARNING: This script deletes ALL fixed assets and their related journal entries (posted or draft). Use this only if you need to wipe clean and re-import.

Usage

Run the script providing the path to odoo-bin, odoo.conf, and the database name:

/path/to/venv/bin/python scripts/delete_all_assets.py \
    <path_to_odoo_bin> \
    <path_to_odoo_conf> \
    <database_name>

Example:

/home/suherdy/Pythoncode/odoo17/.venv/bin/python scripts/delete_all_assets.py \
    /home/suherdy/Pythoncode/odoo17/odoo/odoo-bin \
    /home/suherdy/Pythoncode/odoo17/odoo.conf \
    kipasdbclone5

Requirements

  1. Modules: The asset_code_field custom module (in customaddons/) must be installed.
  2. Python Packages: openpyxl, python-dateutil.