- saat.transaksi.create/write/unlink memicu rekalkulasi portofolio otomatis (buka menu Portofolio selalu data segar, tanpa klik manual) - Tambah tombol 'Rekalkulasi' di form portofolio sbg cadangan (action_recalc_click) - Perbaiki help teks portofolio yg sebelumnya menyesatkan
82 lines
3.2 KiB
Markdown
82 lines
3.2 KiB
Markdown
# Aplikasi Catat Jual-Beli Saham — Odoo 17 + Flutter
|
|
|
|
Backend Odoo ERP (Community 17) untuk mencatat pembelian & penjualan saham,
|
|
diakses dari aplikasi **Flutter** (Android).
|
|
|
|
## Arsitektur
|
|
```
|
|
Flutter app (Android) ──JSON-RPC──► Odoo 17 (Python)
|
|
│ custom addon: saat_invest
|
|
▼
|
|
PostgreSQL 16
|
|
```
|
|
|
|
## Stack
|
|
|
|
| Layer | Teknologi | Port |
|
|
|---|---|---|
|
|
| Backend | Odoo 17 Community (`odoo:17.0`) | `18069` (host) |
|
|
| Database | PostgreSQL 16 (`postgres:16`) | internal (5432, tdk di-publish) |
|
|
| Mobile | Flutter (Android) | — |
|
|
|
|
## Struktur proyek
|
|
```
|
|
saat-app/
|
|
├── docker-compose.yml # Odoo 17 + PostgreSQL 16
|
|
├── .env # RAHASIA: password (jangan commit)
|
|
├── addons/ # custom addon buatan sendiri (saat_invest)
|
|
└── README.md
|
|
```
|
|
|
|
## Cara menjalankan
|
|
```bash
|
|
cd /home/ardhi/Application/saat-app
|
|
docker compose config # validasi
|
|
docker compose up -d # start
|
|
```
|
|
|
|
Akses UI: http://localhost:18069 — login `admin` / `admin`
|
|
(`ADMIN_PASSWORD` untuk Database Management di `.env`).
|
|
|
|
## Status
|
|
- ✅ Odoo 17 container jalan (port 18069), DB PostgreSQL 16 healthy
|
|
- ✅ JSON-RPC aktif (uid `admin` verified) — endpoint yang akan dipakai Flutter
|
|
- ✅ **Addon `saat_invest` terinstal** (model saham, transaksi, portofolio + seed 5 saham IDX)
|
|
- ✅ **Portofolio auto-sync**: otomatis diperbarui tiap transaksi ditambah/ubah/hapus
|
|
(tidak perlu tombol manual; buka menu Portofolio selalu datanya segar)
|
|
- ✅ End-to-end teruji: buat beli/jual → portofolio ter-update → hitung avg cost & realized/unrealized P/L
|
|
- ⏳ Aplikasi Flutter (login, catat jual/beli, portfolio, P/L)
|
|
|
|
## Install / upgrade addon saat_invest
|
|
```bash
|
|
cd /home/ardhi/Application/saat-app
|
|
set -a && source .env && set +a
|
|
# install pertama kali
|
|
docker exec -e PASSWORD="$POSTGRES_PASSWORD" saat-odoo odoo \
|
|
-d "$POSTGRES_DB" --db_host=db --db_user="$POSTGRES_USER" \
|
|
--db_password="$POSTGRES_PASSWORD" --no-http --stop-after-init -i saat_invest
|
|
# upgrade setelah ubah kode
|
|
docker exec -e PASSWORD="$POSTGRES_PASSWORD" saat-odoo odoo \
|
|
-d "$POSTGRES_DB" --db_host=db --db_user="$POSTGRES_USER" \
|
|
--db_password="$POSTGRES_PASSWORD" --no-http --stop-after-init -u saat_invest
|
|
docker restart saat-odoo
|
|
```
|
|
|
|
> Catatan Odoo: `<list>` view di Odoo 17 kadang bermasalah, pakai `<tree>`
|
|
> (kompatibel lintas versi) seperti yang sudah dilakukan.
|
|
|
|
## API untuk Flutter (via JSON-RPC `execute_kw`)
|
|
Semua melalui `POST /jsonrpc` dengan `{service:'object', method:'execute_kw'}`.
|
|
Login: `common.authenticate(db, user, pass)` → `uid`.
|
|
- List saham: `saat.saham search_read [domain] {fields}`
|
|
- Catat transaksi: `saat.transaksi create [{vals}]`
|
|
- List transaksi: `saat.transaksi search_read [domain] {fields}`
|
|
- **Rekalkulasi portofolio**: `saat.portofolio action_recalculate [[]]`
|
|
- Baca portofolio: `saat.portofolio search_read [domain] {fields}`
|
|
(sisa_lembar, avg_cost, total_beli_biaya, realized_pl, unrealized_pl, nilai_sekarang)
|
|
|
|
## Catatan keamanan
|
|
- `.env` berisi rahasia → **tidak boleh di-commit** (sudah di `.gitignore`)
|
|
- PostgreSQL tidak di-publish ke host, hanya akses antar-container
|
|
- Ganti `ADMIN_PASSWD` segera setelah setup awal
|