Doc_chelvyn/Mito/Mito — Index.md

167 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
judul: Mito — Index Dokumentasi
proyek: Mito
modul: mito_odoo (mito_base · snk_jobsheet_operation · jubelio_connector)
odoo: "18.0"
repo: https://repo.sinerka.id/MITO/mito_odoo
tags:
- mito
- index
diperbarui: 2026-10-17
---
# Mito — Index Dokumentasi
Hub semua catatan `mito_odoo` (sales, jobsheet, discount/loyalty, financial report, performa, infra).
Mulai dari sini, jangan telusuri folder satu-satu.
> [!tip] Cara pakai
> Tiap baris di bawah adalah wikilink — klik untuk buka. Kolom **Status** menunjukkan
> apakah pekerjaannya sudah selesai, masih tracking, atau masih menunggu keputusan.
> [!info] Asal dokumen
> Semua dokumen di folder ini diangkat dari catatan mentah di `snk_mito/config/*.md`
> (repo lokal). Field `sumber:` di frontmatter tiap dokumen menunjuk ke file aslinya.
---
## 🚀 Rilis & Deploy
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Upgrade Playbook Production]] | **Baca ini sebelum upgrade apa pun di production.** Klasifikasi code-only vs structural change, urutan eksekusi 2 app server + RDS shared, larangan keras, catatan khusus RDS. Dilengkapi tabel 3 insiden yang melatarinya | ✅ Aktif — playbook wajib |
| [[Mito — Catatan Cepat Upgrade & Migrasi]] | Perintah `-u` yang dipakai sehari-hari di dev + alasan penghapusan table dipindah ke migration script | 📌 Catatan cepat |
> [!warning] Pola yang berulang di Mito
> Tiga insiden terakhir akarnya sama: **fix sudah benar di repo tapi belum sampai ke production**,
> lalu upgrade dipaksa jalan saat kedua server tidak konsisten. Lihat
> [[Mito — Upgrade Playbook Production#Insiden yang melatari playbook ini|tabel insiden]].
---
## 🖥️ Infra
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Jenkins Deploy Gagal (Git Auth Token)]] | **Deploy Jenkins gagal di 6 server** dengan `could not read Username for 'https://repo.sinerka.id'`. Root cause: remote git berformat token-only (`https://TOKEN@`), sehingga request lanjutan kena `401`. Fix: `https://oauth2:TOKEN@`. Berisi bukti trace HTTP, inventaris 6 server, script fix, rencana rotate token, dan stage Preflight Jenkins supaya kegagalan tidak meninggalkan server dalam kondisi drift | 🔄 HO fix & deploy sukses · 5 server belum terverifikasi |
> [!danger] Pipeline deploy bisa meninggalkan server dalam kondisi drift
> Jenkins deploy server satu per satu dan berhenti di server pertama yang gagal. Di insiden
> 2026-10-17, HO sudah ter-restart dengan kode baru sementara 5 server lain masih di versi lama.
> Pola yang sama dengan [[Mito — Upgrade Playbook Production#Insiden yang melatari playbook ini|insiden upgrade]].
---
## ⚡ Performa
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Audit Memory Limit SO Add Product]] | **Penyebab OOM saat add product di SO.** Biang kerok: `_compute_snk_current_credit_limit_so` men-`search()` seluruh invoice customer tiap `amount_total` berubah → `_fetch_field()` prefetch 168 kolom `account_move` × N invoice. Plus 6 temuan pendukung (logging di compute panas, tab Discount 22 kolom, `compute_all()` tanpa cache, `sale_product_pack`) dan kenapa RSS tidak pernah turun (threaded mode + `limit_time_real = 0`). **Dilengkapi hasil load test terukur + harness di `tools/loadtest/`** | 🔄 P0 fixed & teruji (belum deploy) · P1–P2 belum |
> [!danger] Satu temuan menjelaskan hampir semuanya
> `mito/mito_base/models/sale/sale_order.py:431` — `search()` seluruh invoice
> customer tiap `amount_total` berubah, lalu `.filtered()` di Python. Akses satu
> field bikin Odoo prefetch **semua** kolom `account_move` (168 kolom) untuk
> **semua** baris. Terukur: **34 MB + 598 ms per klik** pada customer 5.000 invoice.
>
> ✅ **Sudah di-fix 2026-09-30** — diganti `_read_group` dengan filter di-expand ke
> `state` + `payment_state`. Terukur **97× lebih cepat, 634× lebih hemat memory,
> 5.000 → 0 record di ORM cache**, hasil sama dengan ground truth SQL.
> **Code-only, tapi belum dideploy: butuh restart container di kedua server.**
>
> ⚠️ **Jangan pakai `status_in_payment` di domain.** Di build Mito
> (`18.0-20250918`) field itu tidak searchable, dan `expression.py` **membuang
> leaf-nya secara SENYAP** — filter hilang, total jadi ikut menghitung draft/cancel/
> paid, tanpa exception. Fix versi pertama kena ini dan hampir lolos.
>
> Masih menggantung: `store=True` yang bikin nilainya stale, dan **`db_maxconn = 32`
> yang menolak 74 dari 100 user konkuren** (load test 2026-09-30).
---
## 💸 Discount & Loyalty
Area paling banyak masalahnya — tiga dokumen, saling terkait.
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Diskon Bertingkat & Loyalty Reward]] | `_apply_tiered_discount` cuma baca `discount` + `discount_line_product_id`, 6 field `loyalty.reward` lain diabaikan → 4 skenario gagal (`specific`, `discount_max_amount`, `discount_mode`, `reward_type`) + fix plan 4 langkah. Termasuk fix cascade `_compute_snk_discounts` (2026-06-08) | 🔄 Fix plan — cascade sudah di-fix, sisanya belum |
| [[Mito — Discount Kebagi Dua saat Ada Ongkir]] | Discount jadi dobel di SO yang ada baris ongkir: wizard group per kombinasi pajak, barang ber-VAT vs ongkir tanpa pajak = 2 group. Beda lokal/dev murni **data pajak produk ongkir**, bukan kode. Berisi query psql + pola log siap pakai | 🔍 Tracking — root cause jelas, fix belum diputuskan |
| [[Mito — Free Product Wizard]] | Plan B untuk free product `buy_x_get_y`: wizard manual, line dibuat **tanpa `reward_id`** sehingga mesin loyalty tidak pernah me-recalculate discount-nya | ✅ Selesai · `snk_jobsheet_operation` 18.0.1.0.1 |
---
## 📊 Financial Report
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Perbaikan Financial Invoice Report]] | Permintaan dari sisi tampilan: field mana yang dibuat absolut/minus untuk Customer Invoice & Credit Note, plus laporan nilai HPP dobel saat qty > 1 | ⚠️ Belum ditandai selesai |
Akar masalah HPP-nya dibahas di [[Mito — Plan & Tracking Logika Bisnis]] —
lihat bagian fix `snk_cogs` dan isu negative stock.
---
## 🔌 SFA — CMS Integration
Integrasi `Odoo 18 → CMS → SFA Mobile`. Punya index sendiri karena dokumennya datang dari
tim luar dan repo aplikasinya terpisah.
| Index | Isi | Status |
|---|---|---|
| [[SFA — Index]] | 3 dokumen: deployment production SFA-CMS di VPS (satu server dengan Odoo), setup development lokal, dan FDD Master Product v1.0 (pola **pull** — scheduler di CMS, Odoo cuma API provider) | ⚠️ Belum bisa mulai implementasi · ada to-do security prioritas tinggi |
---
## 🗺️ Plan & Tracking
| Dokumen | Isi | Status |
|---|---|---|
| [[Mito — Plan & Tracking Logika Bisnis]] | Tiga perubahan berdampak luas beserta keputusan bisnis & konsekuensinya: **bypass global discount** (boleh numpuk tanpa batas, tanpa guard), **fix HPP `snk_cogs` selalu 0** (filter `expense_direct_cost`), dan **negative stock → COGS 0** | 2 selesai · 2 pending |
---
## Yang Masih Menggantung
| Hal | Dokumen | Butuh apa |
|---|---|---|
| SO add product bikin OOM — P0 sudah di-fix di repo, **belum dideploy** | [[Mito — Audit Memory Limit SO Add Product]] | Build/pull ke kedua app server + restart container (code-only, Bagian B playbook) |
| `snk_current_credit_limit_so` `store=True` tapi nilainya stale (tidak ikut update saat invoice dibayar) | [[Mito — Audit Memory Limit SO Add Product]] | Keputusan: buang `store=True` (butuh migration drop kolom) atau pindah ke cron |
| `sale_product_pack` terpasang — belum jelas dipakai atau tidak | [[Mito — Audit Memory Limit SO Add Product]] | `SELECT COUNT(*) FROM product_template WHERE pack_ok = true;` → uninstall atau guard |
| Odoo production masih threaded mode, tanpa `workers` / `limit_memory_*` / timeout | [[Mito — Audit Memory Limit SO Add Product]] | Jumlah CPU core server sebenarnya, untuk formula `(2 × core) + 1` |
| **`db_maxconn = 32` menolak 74 dari 100 user konkuren** (terukur di load test) | [[Mito — Audit Memory Limit SO Add Product]] | Naikkan `db_maxconn` **dan** pasang `workers` — fix kode tidak menolong untuk ini |
| Laporan HPP/GPM historis semuanya salah (HPP=0, Ratio GPM=100%) | [[Mito — Plan & Tracking Logika Bisnis]] | Re-generate `snk_financial_report` untuk **semua user**, bukan cuma data baru |
| HPP ke-duplikasi di invoice dengan banyak baris produk sama (IMEI tracking, pernah 799 baris) | [[Mito — Plan & Tracking Logika Bisnis]] | Alokasi proporsional per qty di LATERAL cogs — pola-nya ikut cara ongkir |
| 54 baris HPP masih 0 setelah fix | [[Mito — Plan & Tracking Logika Bisnis]] | Ukur skala `stock_valuation_layer` outgoing ber-`value = 0`, cek apakah PR `da1e478` sudah meng-cover re-valuasi |
| Discount kebagi dua saat ada ongkir | [[Mito — Discount Kebagi Dua saat Ada Ongkir]] | Keputusan: samakan pajak produk ongkir, atau ubah logika grouping di wizard |
| Loyalty reward `specific` / `discount_max_amount` / `per_order` masih diabaikan | [[Mito — Diskon Bertingkat & Loyalty Reward]] | Kerjakan Step 1–4 di fix plan |
| **Token git `repo.sinerka.id` tersimpan plaintext di 6 server dan sempat terekspos di log** | [[Mito — Jenkins Deploy Gagal (Git Auth Token)]] | Rotate token (read-only, repo tunggal), update remote 6 server, revoke token lama |
| Pipeline Jenkins tanpa preflight, gagal di tengah jalan bikin server drift | [[Mito — Jenkins Deploy Gagal (Git Auth Token)]] | Tambah stage Preflight (`git fetch` di semua server) sebelum restart apa pun |
| Global discount boleh numpuk **tanpa guard** — total order bisa minus | [[Mito — Plan & Tracking Logika Bisnis]] | Sudah disepakati bisnis. Guard `amount_total < 0` baru dibuat kalau ada keluhan |
| Nama field teknis Odoo untuk API Master Product masih `TBD` semua | [[SFA — Index]] | Kita yang harus isi dari sisi Odoo, lalu konfirmasi ke tim CMS |
| Belum jelas sync-nya full atau incremental (`write_date`) | [[SFA — Index]] | Jawaban tim CMS — paling menentukan beban query ke RDS |
| Ada **2 instalasi SFA-CMS** hidup bersamaan, FDD tidak sebut targetnya yang mana | [[SFA — Index]] | Keputusan tim/client soal nasib instalasi lama `cms.mito.co.id` (masih pegang data produksi) |
| Password admin default CMS baru belum diganti · port 3306 terbuka publik · belum ada backup DB | [[SFA CMS — Deployment VPS MITO]] | Tindakan langsung — 3 item prioritas tinggi |
---
## Konvensi Folder
```
Mito/
├── Mito — Index.md ← kamu di sini
├── Rilis & Deploy/ playbook upgrade + catatan perintah
├── Infra/ server, pipeline Jenkins, git/credential, incident infra
├── Performa/ audit memory/query, bottleneck, tuning
├── Discount & Loyalty/ diskon bertingkat, ongkir, free product
├── Financial Report/ invoice report & HPP dari sisi laporan
├── Plan & Tracking/ perubahan logika berdampak luas + keputusan bisnis
└── Sfa/ SFA-CMS: deployment, setup lokal, FDD integrasi
├── SFA — Index.md sub-index → dari sini baru ke dokumen
├── Deploy & Setup/
└── FDD/
```
Dokumen baru → taruh di folder kategorinya, lalu tambahkan barisnya di tabel atas.
Kalau satu kasus sudah punya 3 dokumen atau lebih, pisahkan jadi folder kasus sendiri.