Lewati ke isi

Struktur Direktori & Model Reference

Struktur Direktori

edig_expense/
  __manifest__.py              # Odoo 19, pre/post_init_hook
  hooks.py                     # COA & journal creation (idempotent)
  models/
    edig_expense.py            # Main unified model (~1400 lines)
    edig_expense_line.py       # Line items + attachment + rate auto-fill
    edig_expense_zona_rate.py  # Zone-position rate lookup
    edig_expense_kota.py       # City-to-zone mapping
    hr_employee.py             # jabatan_bpd field
    res_company.py             # um_advance_account_id fields
    res_config_settings.py     # Settings UI transient
  views/
    edig_expense_views.xml         # Form, list, kanban, search + employee inherit
    edig_expense_config_views.xml  # Zona rate & kota config
    edig_expense_menus.xml         # Menu + dashboard action
    res_config_settings_views.xml  # Settings page
  data/
    edig_expense_sequence.xml          # 4 sequences
    edig_expense_coa_data.xml          # Product templates & categories
    edig_expense_kota_data.xml         # 100+ cities with zone
    edig_expense_zona_rate_data.xml    # 75 rate records
    edig_expense_mail_templates.xml    # Email notifications
  security/
    edig_expense_security.xml    # 4 groups + record rules
    ir.model.access.csv          # Model-level ACL
  wizards/
    edig_expense_bulk_wizard.py          # Gemini Vision OCR
    edig_expense_bulk_wizard_views.xml
  static/src/
    js/expense_dashboard.js      # OWL dashboard
    js/expense_bon_viewer.js     # Lightbox zoom/pan/PDF
    css/  xml/                   # Styles & QWeb templates
  report/
    edig_expense_report.xml      # Print report
  docs/
    DEVELOPER_GUIDE.md
    Edig_Expense_Testing_Guide.pdf

Model Reference

edig.expense (Main Model)

Inherits: mail.thread, mail.activity.mixin, analytic.mixin

Core Fields

Field Type Notes
name Char Auto-sequence, readonly
type Selection advance / reimburse / realisasi / company_paid
category Selection bpd / operasional
state Selection Lihat State Machine & Workflow
source_type Selection standalone / pr
employee_id M2O hr.employee Default: current user's employee
department_id M2O hr.department Related from employee (stored)
manager_id M2O hr.employee Computed from employee.parent_id
pic_id M2O hr.employee PIC Project (optional)
approver_1_id M2O hr.employee PIC atau manager (computed)
approver_2_id M2O hr.employee Atasan PIC jika PIC di-set
amount Monetary Computed from lines
payment_method Selection transfer / cash
purpose Text Keperluan
line_ids O2M edig.expense.line Rincian biaya

BPD-Specific Fields

Field Type Notes
kota_id M2O edig.expense.kota Auto-set zona via onchange
zona Selection a/b/c/ln_a/ln_b (dari kota)
jabatan Selection Computed dari employee.jabatan_bpd, readonly
zona_rate Float Auto: ZonaRate.get_rate(zona, jabatan)
date_start / date_end Date Tanggal berangkat/kembali
days_count Integer Computed: (end - start).days + 1
pengikut_ids M2M hr.employee Pengikut perjalanan

Parent-Child (Advance <-> Realisasi)

Field Type Notes
parent_id M2O edig.expense UM induk (untuk realisasi)
child_ids O2M edig.expense Semua realisasi dari UM ini
total_realisasi Monetary Sum of done children
selisih Monetary abs(amount - total_realisasi)
selisih_type Selection kembali / reimburse / pas

Accounting Fields

Field Type Notes
disburse_move_id M2O account.move Jurnal pencairan
settlement_move_id M2O account.move Jurnal settlement
return_move_id M2O account.move Jurnal pengembalian sisa
settlement_state Selection draft/submitted/approved/done

Key Methods

Method Fungsi
_compute_jabatan() Auto-fill dari employee.jabatan_bpd
_compute_zona_rate() Lookup ZonaRate.get_rate()
_compute_approvers() Resolve approver_1/2 dari PIC atau manager
_generate_bpd_planning_lines() Auto-create 4 lines (tunjangan, penginapan, transport, entertainment)
_refresh_line_rates() Update unit_price dari zona rate
_create_disburse_move() Debit UM, Credit Bank/Cash
_create_settlement_move() Settle UM + expense accounts
_create_return_move() Return excess ke perusahaan
_auto_reconcile_um_account() Post & reconcile UM account
_finalize_settlement() Update parent UM saat realisasi done
get_dashboard_data() KPI data untuk OWL dashboard

edig.expense.line

Inherits: analytic.mixin

Field Type Notes
expense_id M2O edig.expense Parent (cascade)
expense_type Selection tunjangan/transport/penginapan/transport_lokal/entertainment/pembelian/pengiriman/lain_lain
product_id M2O product.product Auto-suggest dari expense_type
account_id M2O account.account Akun biaya (untuk jurnal)
quantity Float Default 1.0, tunjangan = days_count
unit_price Monetary Manual atau auto dari zona rate
subtotal Monetary qty x unit_price
attachment_ids M2M ir.attachment Bukti bon/struk

Key behavior:

  • _onchange_expense_type_suggest_product() - auto-map expense_type ke product (Sales vs Service context)
  • _auto_fill_rate() - lookup rate dari zona_rate table, set unit_price + qty

edig.expense.zona.rate

Field Type Notes
zona Selection a/b/c/ln_a/ln_b
jabatan Selection direktur_utama/direktur/manager/supervisor/officer
rate_type Selection tunjangan/penginapan/entertainment
amount Float Nilai rate
currency_note Char IDR (domestik) / USD (internasional)

Constraint: UNIQUE(zona, jabatan, rate_type) - total 75 records.

API: ZonaRate.get_rate(zona, jabatan, rate_type) - returns amount atau 0.0

hr.employee Extension

Field tambahan: jabatan_bpd (Selection) - diset oleh HR, dipakai untuk auto-fill jabatan di expense (readonly).

Nilai: direktur_utama, direktur, manager, supervisor, officer


Selanjutnya: State Machine & Workflow | Sebelumnya: Overview & Arsitektur