126 lines
4.0 KiB
Markdown
126 lines
4.0 KiB
Markdown
# 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.
|
|
- **Auto-Posting**: Automatically posts depreciation entries for **past and current dates**.
|
|
- **Cron Ready**: Sets future depreciation entries to `auto_post='at_date'` so Odoo's standard cron picks them up.
|
|
- **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:
|
|
|
|
```bash
|
|
/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:**
|
|
```bash
|
|
/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
|
|
```bash
|
|
/path/to/venv/bin/python scripts/post_depreciation.py \
|
|
<path_to_odoo_bin> \
|
|
<path_to_odoo_conf> \
|
|
<database_name> \
|
|
[--date YYYY-MM-DD]
|
|
```
|
|
|
|
**Example:**
|
|
```bash
|
|
/home/suherdy/Pythoncode/odoo17/.venv/bin/python scripts/post_depreciation.py \
|
|
/home/suherdy/Pythoncode/odoo17/odoo/odoo-bin \
|
|
/home/suherdy/Pythoncode/odoo17/odoo.conf \
|
|
kipasdbclone5 \
|
|
kipasdbclone5 \
|
|
--date 2026-01-21
|
|
```
|
|
|
|
---
|
|
|
|
## 3. Post Missing Depreciations (`post_missing_depreciations.py`)
|
|
Use this script to retroactive fix assets that were imported but have their depreciation entries stuck in **Draft** state.
|
|
|
|
### Features
|
|
- Finds all **Running** assets.
|
|
- Posts `Draft` depreciation moves for **past and current dates**.
|
|
- Updates **future** `Draft` moves to have `auto_post='at_date'`, ensuring Odoo's cron processes them later.
|
|
|
|
### Usage
|
|
```bash
|
|
/path/to/venv/bin/python scripts/post_missing_depreciations.py \
|
|
<path_to_odoo_bin> \
|
|
<path_to_odoo_conf> \
|
|
<database_name>
|
|
```
|
|
|
|
**Example:**
|
|
```bash
|
|
/home/suherdy/Pythoncode/odoo17/.venv/bin/python scripts/post_missing_depreciations.py \
|
|
/home/suherdy/Pythoncode/odoo17/odoo/odoo-bin \
|
|
/home/suherdy/Pythoncode/odoo17/odoo.conf \
|
|
kipasdbclone5
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Check Auto Post Status (`check_auto_post.py`)
|
|
A simple diagnostic utility to check if the `auto_post` field is correctly set on draft depreciation moves.
|
|
|
|
### Usage
|
|
```bash
|
|
/path/to/venv/bin/python scripts/check_auto_post.py \
|
|
<path_to_odoo_bin> \
|
|
<path_to_odoo_conf> \
|
|
<database_name>
|
|
```
|
|
|
|
|
|
---
|
|
|
|
## 5. 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:
|
|
|
|
```bash
|
|
/path/to/venv/bin/python scripts/delete_all_assets.py \
|
|
<path_to_odoo_bin> \
|
|
<path_to_odoo_conf> \
|
|
<database_name>
|
|
```
|
|
|
|
**Example:**
|
|
```bash
|
|
/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`.
|