ERP: unique index item_code, dokumentasi README, migration script update
This commit is contained in:
19
README.md
19
README.md
@@ -73,7 +73,22 @@ Addon kustom dalam folder `./addons/kosbar_erp_ext/` menyediakan:
|
||||
|
||||
---
|
||||
|
||||
## 4. Struktur Database Utama (PostgreSQL)
|
||||
## 4. Product Category Code & Item Code
|
||||
|
||||
### Field Baru (Auto-generated):
|
||||
* **Category Code** (`product.category.code`)
|
||||
- 2 digit berdasarkan ID kategori
|
||||
- Contoh: ID=1 → `01`, ID=7 → `07`, ID=10 → `10`
|
||||
|
||||
* **Item Code** (`product.template.item_code`)
|
||||
- Kombinasi: `parent_kode` (2 digit) + `kategori_kode` (2 digit) + `id_produk` (4 digit) + `nama_slug` (lowercase, tanpa spasi)
|
||||
- Contoh: Kategori `05` (anak dari `01`), Produk ID=1, nama="Laptop ASUS"
|
||||
- → `item_code = 01050001laptopasus`
|
||||
- *Item Code otomatis diisi saat produk dibuat/diupdate.*
|
||||
|
||||
---
|
||||
|
||||
## 5. Struktur Database Utama (PostgreSQL)
|
||||
|
||||
Tabel inti Odoo 19 yang digunakan dalam alur di atas:
|
||||
|
||||
@@ -99,7 +114,7 @@ Tabel inti Odoo 19 yang digunakan dalam alur di atas:
|
||||
|
||||
---
|
||||
|
||||
## 5. Perintah Manajemen Docker
|
||||
## 6. Perintah Manajemen Docker
|
||||
|
||||
* **Menjalankan stack:**
|
||||
```bash
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import re
|
||||
|
||||
# Migration: isi code kategori & item_code produk untuk data existing
|
||||
env.cr.execute(
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS product_template_item_code_uniq "
|
||||
"ON product_template (item_code) WHERE item_code IS NOT NULL"
|
||||
)
|
||||
env.cr.commit()
|
||||
|
||||
cats = env['product.category'].search([])
|
||||
for c in cats:
|
||||
if not c.code:
|
||||
|
||||
Reference in New Issue
Block a user