diff --git a/templates/README-IMPORT.md b/templates/README-IMPORT.md new file mode 100644 index 0000000..7434dd3 --- /dev/null +++ b/templates/README-IMPORT.md @@ -0,0 +1,24 @@ +# Template Import Odoo + +Folder ini berisi contoh file template untuk import master data ke Odoo ERP. + +## Isi Folder +| File | Kegunaan | +|---|---| +| `import-products.xlsx` | Template import produk (Product Name, Category, Price, Cost, Barcode) | +| `import-product-categories.xlsx` | Template import kategori produk (Name + Parent Category) | +| `import-product-categories.csv` | Versi CSV kategori (untuk referensi/format cepat) | + +## Cara Pakai +1. **Kategori dulu, baru Produk** (Produk butuh kategori yang sudah ada). +2. Buka Odoo → **Inventory/Sales → Configuration → Product Categories** → tombol **Import**. + - Petakan: `Nama Kategori` → `Name`, `Parent Category` → `Parent Category`. +3. Setelah kategori masuk, `code` 2-digit otomatis terisi oleh addon. +4. Buka **Inventory/Sales → Products → Products** → tombol **Import**. + - Petakan: `Product Name` → `Name`, `Product Category` → `Product Category`, dll. +5. **Jangan isi** kolom `Item Code`/`Internal Reference` — otomatis di-generate addon. + - Format: `parent_code + child_code + product_id(4) + nama_lowercase_tanpa_spasi (koma → titik)`. + +## Contoh hasil otomatis +- Kategori `Elektronik` (code `01`), kategori `Laptop` (code `04`, parent `Elektronik`), produk `MacBook Air M2` (id `0001`): + - `item_code = 01040001macbookairm2` diff --git a/templates/generate_templates.py b/templates/generate_templates.py new file mode 100644 index 0000000..4ffa20d --- /dev/null +++ b/templates/generate_templates.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +"""Generate template Excel untuk import produk & kategori Odoo.""" +from openpyxl import Workbook +from openpyxl.styles import Font, PatternFill, Alignment + +HEADER_FILL = PatternFill('solid', fgColor='0B6E4F') +HEADER_FONT = Font(bold=True, color='FFFFFF') + +def styled_header(ws, headers): + ws.append(headers) + for cell in ws[1]: + cell.fill = HEADER_FILL + cell.font = HEADER_FONT + cell.alignment = Alignment(horizontal='center') + +# ---------- 1. Template Produk ---------- +wb = Workbook() +ws = wb.active +ws.title = 'Products' +styled_header(ws, ['Product Name', 'Product Category', 'Sales Price', 'Cost', 'Barcode']) + +rows = [ + ['iPhone 15 128GB', 'Smartphone', 15000000, 12000000, 1234567890123], + ['Samsung Galaxy S24', 'Smartphone', 14000000, 11000000, 1234567890124], + ['MacBook Air M2', 'Laptop', 25000000, 20000000, 1234567890125], + ['Wireless Mouse', 'Mouse', 500000, 350000, 1234567890126], + ['Mechanical Keyboard', 'Keyboard', 750000, 500000, 1234567890127], +] +for r in rows: + ws.append(r) + +widths = [22, 18, 13, 13, 16] +for i, w in enumerate(widths, 1): + ws.column_dimensions[chr(64 + i)].width = w + +wb.save('/home/ardhi/Application/odoo-erp/templates/import-products.xlsx') +print('OK: import-products.xlsx') + +# ---------- 2. Template Kategori ---------- +wb2 = Workbook() +ws2 = wb2.active +ws2.title = 'Categories' +styled_header(ws2, ['Nama Kategori', 'Parent Category']) + +cat_rows = [ + ['Elektronik', ''], + ['Smartphone', 'Elektronik'], + ['Laptop', 'Elektronik'], + ['Aksesoris', ''], + ['Mouse', 'Aksesoris'], + ['Keyboard', 'Aksesoris'], +] +for r in cat_rows: + ws2.append(r) + +ws2.column_dimensions['A'].width = 22 +ws2.column_dimensions['B'].width = 22 + +wb2.save('/home/ardhi/Application/odoo-erp/templates/import-product-categories.xlsx') +print('OK: import-product-categories.xlsx') diff --git a/templates/import-product-categories.csv b/templates/import-product-categories.csv new file mode 100644 index 0000000..00bfe69 --- /dev/null +++ b/templates/import-product-categories.csv @@ -0,0 +1,7 @@ +Nama Kategori,Parent Category +Elektronik, +Smartphone,Electronics +Laptop,Electronics +Aksesoris, +Mouse,Aksesoris +Keyboard,Aksesoris \ No newline at end of file diff --git a/templates/import-product-categories.xlsx b/templates/import-product-categories.xlsx new file mode 100644 index 0000000..2bd71e7 Binary files /dev/null and b/templates/import-product-categories.xlsx differ diff --git a/templates/import-products.xlsx b/templates/import-products.xlsx new file mode 100644 index 0000000..00396f6 Binary files /dev/null and b/templates/import-products.xlsx differ