Compare commits

..

9 Commits

35 changed files with 1910 additions and 22 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,7 @@
.env .env
config/odoo.conf config/odoo.conf
config/odoo18.conf
odoo18/
enterprise/
*.log *.log
.DS_Store .DS_Store

27
Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
FROM odoo:18
USER root
# Install extra system packages if needed
RUN apt-get update && apt-get install -y \
git \
python3-pip \
python3-dev \
build-essential \
libldap2-dev \
libsasl2-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy Odoo source requirements
#COPY ./odoo18/requirements.txt /tmp/requirements.txt
# Install Python dependencies
#RUN pip3 install --break-system-packages -r /tmp/requirements.txt
# Create working directory
WORKDIR /opt/odoo
USER odoo
CMD ["python3", "/opt/odoo/odoo-bin", "-c", "/etc/odoo/odoo.conf"]

View File

@@ -114,7 +114,20 @@ Tabel inti Odoo 19 yang digunakan dalam alur di atas:
--- ---
## 6. Perintah Manajemen Docker ## 6. Master Data Import
Kami menyediakan file template Excel untuk mempercepat input data:
* **Lokasi Template:** `/templates/`
* **File tersedia:**
* `import-products.xlsx`: Template produk.
* `import-product-categories.xlsx`: Template kategori.
* `README-IMPORT.md`: Panduan lengkap import master data.
* **Catatan:** Jangan isi kolom `Item Code` saat import — sistem akan meng-generate-nya otomatis (format: `parent+child+id+name_slug`, koma → titik).
---
## 7. Perintah Manajemen Docker
* **Menjalankan stack:** * **Menjalankan stack:**
```bash ```bash

1468
README_odoo18.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -50,7 +50,8 @@ class ProductTemplate(models.Model):
return f'{parent_code}{own_code}' return f'{parent_code}{own_code}'
def _name_slug(self, name): def _name_slug(self, name):
return re.sub(r'\s+', '', (name or '').lower()) slug = (name or '').lower().replace(',', '.')
return re.sub(r'\s+', '', slug)
def _full_item_code(self, obj): def _full_item_code(self, obj):
"""Compute full item_code: prefix kategori + id:04d + name_slug.""" """Compute full item_code: prefix kategori + id:04d + name_slug."""

View File

@@ -20,10 +20,13 @@ class SaleOrder(models.Model):
order.name = seq.with_date(order.date_order or fields.Date.context_today(self)).next_by_code() order.name = seq.with_date(order.date_order or fields.Date.context_today(self)).next_by_code()
return super().action_confirm() return super().action_confirm()
@api.model @api.model_create_multi
def create(self, vals): def create(self, vals_list):
"""When creating a quotation (draft), use SQ sequence.""" """When creating quotations (draft), use the SQ sequence."""
for vals in vals_list:
if vals.get('state') == 'draft' and not vals.get('name'): if vals.get('state') == 'draft' and not vals.get('name'):
seq = self._get_quotation_sequence_id() seq = self._get_quotation_sequence_id()
vals['name'] = seq.with_date(vals.get('date_order') or fields.Date.context_today(self)).next_by_code() vals['name'] = seq.with_date(
return super().create(vals) vals.get('date_order') or fields.Date.context_today(self)
).next_by_code()
return super().create(vals_list)

View File

@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<!-- Product Template form: tampilkan Item Code read_only --> <!-- Product Template form: Item Code read_only -->
<record id="view_product_template_item_code" model="ir.ui.view"> <record id="view_product_template_item_code" model="ir.ui.view">
<field name="name">product.template.form.item.code</field> <field name="name">product.template.form.item.code</field>
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/> <field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="default_code" position="after"> <xpath expr="//field[@name='categ_id']" position="after">
<field name="item_code" readonly="1" <field name="item_code" readonly="1"
placeholder="Terisi otomatis dari kategori &amp; nama"/> placeholder="Terisi otomatis setelah simpan"/>
</field> </xpath>
</field> </field>
</record> </record>
<!-- Product Variant form (product.product): Item Code read_only --> <!-- Product Variant/Master form: Item Code read_only -->
<record id="view_product_product_item_code" model="ir.ui.view"> <record id="view_product_product_item_code" model="ir.ui.view">
<field name="name">product.product.form.item.code</field> <field name="name">product.product.form.item.code</field>
<field name="model">product.product</field> <field name="model">product.product</field>
<field name="inherit_id" ref="product.product_variant_easy_edit_view"/> <field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="default_code" position="after"> <xpath expr="//field[@name='categ_id']" position="after">
<field name="item_code" readonly="1"/> <field name="item_code" readonly="1"/>
</field> </xpath>
</field> </field>
</record> </record>
</odoo> </odoo>

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,18 @@
{
'name': 'Kos Barokah Purchase Finance',
'version': '1.0',
'category': 'Purchases',
'summary': 'Permintaan barang gudang + approval PO oleh Finance',
'author': 'Kos Barokah',
'license': 'LGPL-3',
'depends': ['purchase', 'stock', 'product', 'kosbar_erp_ext'],
'data': [
'security/res_groups.xml',
'security/ir.model.access.csv',
'data/ir_sequence.xml',
'views/purchase_request_views.xml',
'views/purchase_order_views.xml',
],
'installable': True,
'application': False,
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="seq_purchase_request" model="ir.sequence">
<field name="name">Purchase Request Kos Barokah</field>
<field name="code">kosbar.purchase.request</field>
<field name="padding">5</field>
<field name="prefix">PR/%(year)s/</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,2 @@
from . import purchase_request
from . import purchase_order

View File

@@ -0,0 +1,24 @@
from odoo import models, fields, api
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
finance_state = fields.Selection([
('pending', 'Pending Approval'),
('approved', 'Finance Approved'),
('rejected', 'Rejected'),
], string='Status Finance', default='pending', tracking=True)
def action_finance_approve(self):
"""Finance mengklik ini setelah review PO."""
return self.write({'finance_state': 'approved'})
def action_finance_reject(self):
"""Finance menolak PO — ada catatan di notes."""
return self.write({'finance_state': 'rejected'})
@api.model
def _get_state_color(self):
# optional: styling di kanban view
return {'pending': 'warning', 'approved': 'success', 'rejected': 'danger'}

View File

@@ -0,0 +1,79 @@
from odoo import models, fields, api
class PurchaseRequest(models.Model):
_name = 'kosbar.purchase.request'
_description = 'Purchase Request dari Gudang'
_order = 'id desc'
name = fields.Char(
string='Nomor Request',
required=True,
copy=False,
readonly=True,
default='New',
)
user_id = fields.Many2one(
'res.users',
string='Diminta Oleh',
default=lambda self: self.env.user,
required=True,
)
date_required = fields.Date(string='Tanggal Dibutuhkan', default=fields.Date.today())
state = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
('approved', 'Approved / In Progress'),
('done', 'Done'),
('rejected', 'Rejected'),
], string='Status', default='draft', tracking=True)
line_ids = fields.One2many(
'kosbar.purchase.request.line',
'request_id',
string='Daftar Barang',
)
notes = fields.Text(string='Catatan / Keperluan')
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('name', 'New') == 'New':
seq = self.env['ir.sequence'].next_by_code('kosbar.purchase.request')
vals['name'] = seq if seq else 'PR/2026/00001'
return super().create(vals_list)
def action_submit(self):
self.write({'state': 'submitted'})
def action_approve(self):
self.write({'state': 'approved'})
def action_done(self):
self.write({'state': 'done'})
def action_reject(self):
self.write({'state': 'rejected'})
def action_draft(self):
self.write({'state': 'draft'})
class PurchaseRequestLine(models.Model):
_name = 'kosbar.purchase.request.line'
_description = 'Detail Item Purchase Request'
request_id = fields.Many2one('kosbar.purchase.request', string='Request Reference', ondelete='cascade')
# Bisa pilih barang existing ATAU buat barang baru langsung
is_new_product = fields.Boolean(string='Barang Baru?', default=False)
product_id = fields.Many2one('product.product', string='Produk (Existing)')
# Jika barang baru
new_product_name = fields.Char(string='Nama Barang Baru')
categ_id = fields.Many2one('product.category', string='Kategori Barang')
product_qty = fields.Float(string='Jumlah', default=1.0, required=True)
product_uom = fields.Many2one('uom.uom', string='Satuan', default=lambda self: self.env.ref('uom.product_uom_unit', raise_if_not_found=False))
price_unit = fields.Float(string='Estimasi Harga Satuan')
notes = fields.Char(string='Keterangan')

View File

@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_purchase_request,access_purchase_request,model_kosbar_purchase_request,base.group_user,1,1,1,0
access_purchase_request_line,access_purchase_request_line,model_kosbar_purchase_request_line,base.group_user,1,1,1,0
access_purchase_order_finance,access_purchase_order_finance,model_purchase_order,kosbar_purchase_finance.group_finance,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_purchase_request access_purchase_request model_kosbar_purchase_request base.group_user 1 1 1 0
3 access_purchase_request_line access_purchase_request_line model_kosbar_purchase_request_line base.group_user 1 1 1 0
4 access_purchase_order_finance access_purchase_order_finance model_purchase_order kosbar_purchase_finance.group_finance 1 1 0 0

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Group Finance khusus -->
<record id="group_finance" model="res.groups">
<field name="name">Finance / Accounting Approval</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Purchase Order : inherit form utk approval finance -->
<record id="view_purchase_order_finance" model="ir.ui.view">
<field name="name">purchase.order.form.finance</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<!-- Tombol approve/reject di header PO -->
<xpath expr="//header" position="inside">
<button name="action_finance_approve" string="Finance Approve"
type="object" class="btn-success"
groups="kosbar_purchase_finance.group_finance"
invisible="finance_state in ['approved','rejected']"/>
<button name="action_finance_reject" string="Finance Reject"
type="object" class="btn-danger"
groups="kosbar_purchase_finance.group_finance"
invisible="finance_state == 'rejected'"/>
</xpath>
<!-- Field status finance di sheet -->
<xpath expr="//sheet/div[hasclass('oe_button_box')]" position="inside">
<field name="finance_state" readonly="1"
class="oe_stat_button" icon="fa-money"/>
</xpath>
</field>
</record>
<!-- Status finance di list view PO -->
<record id="view_purchase_order_finance_tree" model="ir.ui.view">
<field name="name">purchase.order.tree.finance</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_tree"/>
<field name="arch" type="xml">
<field name="state" position="after">
<field name="finance_state" readonly="1"/>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Purchase Request : List view -->
<record id="view_purchase_request_tree" model="ir.ui.view">
<field name="name">kosbar.purchase.request.tree</field>
<field name="model">kosbar.purchase.request</field>
<field name="arch" type="xml">
<list string="Permintaan Barang" editable="bottom">
<field name="name"/>
<field name="user_id"/>
<field name="date_required"/>
<field name="state"/>
</list>
</field>
</record>
<!-- Purchase Request : Form view -->
<record id="view_purchase_request_form" model="ir.ui.view">
<field name="name">kosbar.purchase.request.form</field>
<field name="model">kosbar.purchase.request</field>
<field name="arch" type="xml">
<form string="Permintaan Barang">
<header>
<button name="action_submit" string="Submit" type="object"
class="btn-primary" invisible="state != 'draft'"/>
<button name="action_approve" string="Approved" type="object"
class="btn-success" invisible="state != 'submitted'"/>
<button name="action_done" string="Mark Done" type="object"
class="btn-secondary" invisible="state != 'approved'"/>
<button name="action_reject" string="Reject" type="object"
class="btn-danger" invisible="state != 'submitted'"/>
<button name="action_draft" string="Reset to Draft" type="object"
invisible="state != 'rejected'"/>
<field name="state" widget="statusbar" statusbar_visible="draft,submitted,approved,done"/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="name" readonly="1"/></h1>
</div>
<group>
<group>
<field name="user_id"/>
<field name="date_required"/>
</group>
<group>
<field name="state" readonly="1"/>
</group>
</group>
<notebook>
<page string="Barang">
<field name="line_ids">
<list editable="bottom">
<field name="is_new_product"/>
<field name="product_id" invisible="is_new_product"/>
<field name="new_product_name" invisible="not is_new_product"/>
<field name="categ_id" invisible="not is_new_product"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="price_unit"/>
<field name="notes" optional="show"/>
</list>
</field>
</page>
<page string="Keterangan">
<field name="notes" placeholder="Keperluan / alasan pembelian"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- Action & Menu -->
<record id="action_purchase_request" model="ir.actions.act_window">
<field name="name">Permintaan Barang</field>
<field name="res_model">kosbar.purchase.request</field>
<field name="view_mode">list,form</field>
</record>
<menuitem id="menu_purchase_request"
name="Permintaan Barang"
parent="purchase.menu_purchase_root"
action="action_purchase_request"
sequence="70"/>
</odoo>

View File

@@ -1,5 +1,3 @@
version: '3.8'
services: services:
db: db:
image: postgres:16 image: postgres:16
@@ -12,6 +10,8 @@ services:
- POSTGRES_DB=${POSTGRES_DB:-postgres} - POSTGRES_DB=${POSTGRES_DB:-postgres}
volumes: volumes:
- erp_pgdata:/var/lib/postgresql/data - erp_pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-odoo} -d ${POSTGRES_DB:-postgres}"] test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-odoo} -d ${POSTGRES_DB:-postgres}"]
interval: 10s interval: 10s
@@ -19,7 +19,7 @@ services:
retries: 10 retries: 10
odoo: odoo:
image: odoo:19.0 build: .
container_name: odoo-erp container_name: odoo-erp
restart: unless-stopped restart: unless-stopped
env_file: .env env_file: .env
@@ -35,8 +35,10 @@ services:
- "18070:8069" - "18070:8069"
volumes: volumes:
- erp_webdata:/var/lib/odoo - erp_webdata:/var/lib/odoo
- ./config:/etc/odoo - ./config/odoo18.conf:/etc/odoo/odoo.conf
- ./addons:/mnt/extra-addons - ./odoo18:/opt/odoo
- ./custom_addons:/mnt/extra-addons
- ./enterprise:/mnt/enterprise
command: ["odoo", "-c", "/etc/odoo/odoo.conf"] command: ["odoo", "-c", "/etc/odoo/odoo.conf"]
volumes: volumes:

View File

@@ -0,0 +1,28 @@
# 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`
## Opsi cli
```bash
python3 -m venv /tmp/xlsxenv && /tmp/...
```

View File

@@ -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')

View File

@@ -0,0 +1,7 @@
Nama Kategori,Parent Category
Elektronik,
Smartphone,Electronics
Laptop,Electronics
Aksesoris,
Mouse,Aksesoris
Keyboard,Aksesoris
1 Nama Kategori Parent Category
2 Elektronik
3 Smartphone Electronics
4 Laptop Electronics
5 Aksesoris
6 Mouse Aksesoris
7 Keyboard Aksesoris

Binary file not shown.

Binary file not shown.