240 lines
4.9 KiB
Markdown
240 lines
4.9 KiB
Markdown
|
|
---
|
|||
|
|
proyek: e-Asset Patra Jasa
|
|||
|
|
modul: pj_easset
|
|||
|
|
odoo: 18.0 Community
|
|||
|
|
kategori: Rilis & Deploy
|
|||
|
|
branch: cjdev
|
|||
|
|
status: Selesai
|
|||
|
|
tags:
|
|||
|
|
- easset
|
|||
|
|
- rilis
|
|||
|
|
- opname
|
|||
|
|
- deploy
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
> Index: [[Easset — Index]] · Kategori: **Rilis & Deploy**
|
|||
|
|
|
|||
|
|
Modul: `pj_easset` · Odoo 18 Community · Branch kerja: `cjdev`
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 1. Kuantitas Aktif Opname Auto-Hitung
|
|||
|
|
|
|||
|
|
|
|||
|
|
**Path UI:** Opname → Klik Tombol Scan (halaman scanner mobile)
|
|||
|
|
|
|||
|
|
|
|||
|
|
Field **Aktif** (`inventory_quantity`) di baris opname tidak lagi diisi manual, tapi **dihitung otomatis**:
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Aktif = max(0, Quantity − Rusak − Hilang − Dihapuskan)
|
|||
|
|
|
|||
|
|
inventory_quantity = max(0, quantity − broken_quantity − loss_quantity − dispose_quantity)
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
- Petugas hanya input **Rusak / Hilang / Dihapuskan**; Aktif terisi sendiri.
|
|||
|
|
|
|||
|
|
- Ada guard `max(0, …)` → Aktif tidak pernah minus.
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**Model:** `snk.maintenance.opname.equipment`
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/models/maintenance/snk_maintenance_opname.py`
|
|||
|
|
|
|||
|
|
- `inventory_quantity` → `compute='_compute_inventory_quantity'`, `store=True`, `readonly=True`
|
|||
|
|
|
|||
|
|
- Method `_compute_inventory_quantity` (depends: `quantity`, `broken_quantity`, `loss_quantity`, `dispose_quantity`)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 2. Tombol Submit Disabled Saat Aktif = 0
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Jika ada minimal satu item dengan **Aktif ≤ 0**, tombol **Submit Approval**:
|
|||
|
|
|
|||
|
|
- jadi **disabled** (tidak bisa diklik)
|
|||
|
|
|
|||
|
|
- warna hijau (`btn-success`) → abu-abu (`btn-secondary`)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/static/src/js/opname_mobile_scanner.js`
|
|||
|
|
|
|||
|
|
- Fungsi `refreshSubmitState()` — dicek saat load, tiap update qty, dan backstop di `submitApproval()`
|
|||
|
|
|
|||
|
|
- Input Aktif jadi **readonly** + auto-update dari nilai server tiap Rusak/Hilang/Dihapuskan diubah
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/views/maintenance/snk_maintenance_opname_templates.xml`
|
|||
|
|
|
|||
|
|
- Input Aktif `readonly`, tombol submit diberi `id="submit-btn"`
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 3. Hapus Mode Scan "Bagus" (avail)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Mode `avail` ("Scan Bagus") sudah mubazir karena Aktif kini auto-hitung. Dihapus:
|
|||
|
|
|
|||
|
|
- selection `scan_mode` (tinggal `add` & `broken`)
|
|||
|
|
|
|||
|
|
- blok scan `avail` di `_process_scan`
|
|||
|
|
|
|||
|
|
- method `action_avail`
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/models/maintenance/snk_maintenance_opname.py`
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 4. Controller Scanner Web (penting — sempat kena merge)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/controllers/maintenance/maintenance_opname.py`
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Endpoint **web** (dipakai halaman scanner JS), bukan REST API:
|
|||
|
|
|
|||
|
|
- `/scanner/opname/update` (`update_line`):
|
|||
|
|
|
|||
|
|
- `inventory_quantity` dibuang dari `allowed` (sekarang computed, tak boleh ditulis)
|
|||
|
|
|
|||
|
|
- return menyertakan `inventory_quantity` hasil recompute → JS bisa update Aktif live
|
|||
|
|
|
|||
|
|
- `/scanner/opname/add` (`add_line`): return tambahan `quantity` & `inventory_quantity` untuk baris baru
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
> ⚠️ **Catatan duplikasi controller:** setelah merge `develop` ([FEAT] update respons),
|
|||
|
|
|
|||
|
|
> muncul set endpoint kembar `/api/scanner/...` (`update_line_new`, `add_line_new`,
|
|||
|
|
|
|||
|
|
> `scanner_page_new`) untuk REST API app mobile. Sempat terjadi: fix di endpoint web
|
|||
|
|
|
|||
|
|
> `/scanner/opname/update` "kalah" saat merge (ke-revert ke versi lama tanpa return
|
|||
|
|
|
|||
|
|
> `inventory_quantity`) sehingga **live update gagal, tapi reload jalan**. Sudah
|
|||
|
|
|
|||
|
|
> diperbaiki dengan menyamakan kembali endpoint web. Endpoint `/api/...` (punya tim
|
|||
|
|
|
|||
|
|
> mobile) tidak disentuh.
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 5. Migration
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**File:** `pj_easset/migrations/0.2/post-migrate.py`
|
|||
|
|
|
|||
|
|
- Recompute `inventory_quantity` untuk data opname lama (idempotent)
|
|||
|
|
|
|||
|
|
- `version` manifest dinaikkan `0.1` → `0.2`
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## Cara Deploy
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**Ada perubahan model/field/migration** (poin 1–3, 5):
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
|
|||
|
|
# di server, folder repo addons:
|
|||
|
|
|
|||
|
|
git pull
|
|||
|
|
|
|||
|
|
docker compose run --rm web odoo -u pj_easset -d EASSET --stop-after-init
|
|||
|
|
|
|||
|
|
docker restart patra-easset-dev-web-1
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
**Kalau hanya ubah controller/JS** (poin 4 saja), cukup:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
|
|||
|
|
git pull
|
|||
|
|
|
|||
|
|
docker restart patra-easset-dev-web-1
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Selalu **hard refresh browser** (Cmd/Ctrl+Shift+R) setelahnya — file JS scanner sering ke-cache.
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
> 💡 Aturan emas: `docker compose run --rm web ... -u` hanya mengurus DB/struktur.
|
|||
|
|
|
|||
|
|
> Kode Python di server yang sedang hidup baru ter-load ulang setelah
|
|||
|
|
|
|||
|
|
> `docker restart patra-easset-dev-web-1`. Lupa restart = "sudah upgrade tapi sama saja".
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## Catatan / Known Issue (belum dikerjakan)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
- **Submit lambat ~21 detik:** `opname.request_validation()` (tier validation) mengirim
|
|||
|
|
|
|||
|
|
email notifikasi reviewer secara sinkron; karena SMTP belum dikonfigurasi/tak terjangkau,
|
|||
|
|
|
|||
|
|
Odoo nunggu timeout ~20 detik. Kadang muncul 500 (timeout proxy) → JS tampilkan
|
|||
|
|
|
|||
|
|
"No redirect URL returned" (pesan generik yang menyembunyikan error asli).
|
|||
|
|
|
|||
|
|
**Solusi (belum diterapkan):** panggil dengan `with_context(mail_notify_force_send=False)`
|
|||
|
|
|
|||
|
|
agar email diantrikan ke `mail.mail` (dikirim cron), atau konfigurasi Outgoing Mail Server.
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
- **Field `latest_opname_date`:** RPC_ERROR `column ... does not exist` muncul kalau modul
|
|||
|
|
|
|||
|
|
belum di-`-u` setelah field stored computed ini ditambahkan. Jalankan `-u pj_easset`.
|