Files
goodie/pkg/orm/command.go
Marc 0ed29fe2fd Odoo ERP ported to Go — complete backend + original OWL frontend
Full port of Odoo's ERP system from Python to Go, with the original
Odoo JavaScript frontend (OWL framework) running against the Go server.

Backend (10,691 LoC Go):
- Custom ORM: CRUD, domains→SQL with JOINs, computed fields, sequences
- 93 models across 14 modules (base, account, sale, stock, purchase, hr,
  project, crm, fleet, product, l10n_de, google_address/translate/calendar)
- Auth with bcrypt + session cookies
- Setup wizard (company, SKR03 chart, admin, demo data)
- Double-entry bookkeeping constraint
- Sale→Invoice workflow (confirm SO → generate invoice → post)
- SKR03 chart of accounts (110 accounts) + German taxes (USt/VSt)
- Record rules (multi-company filter)
- Google integrations as opt-in modules (Maps, Translate, Calendar)

Frontend:
- Odoo's original OWL webclient (503 JS modules, 378 XML templates)
- JS transpiled via Odoo's js_transpiler (ES modules → odoo.define)
- SCSS compiled to CSS (675KB) via dart-sass
- XML templates compiled to registerTemplate() JS calls
- Static file serving from Odoo source addons
- Login page, session management, menu navigation
- Contacts list view renders with real data from PostgreSQL

Infrastructure:
- 14MB single binary (CGO_ENABLED=0)
- Docker Compose (Go server + PostgreSQL 16)
- Zero phone-home (no outbound calls to odoo.com)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 01:45:09 +02:00

69 lines
2.0 KiB
Go

package orm
// Command represents an ORM write command for One2many/Many2many fields.
// Mirrors: odoo/orm/fields.py Command class
//
// Odoo uses a tuple-based command system:
//
// (0, 0, {values}) → CREATE: create new record
// (1, id, {values}) → UPDATE: update existing record
// (2, id, 0) → DELETE: delete record
// (3, id, 0) → UNLINK: remove link (M2M only)
// (4, id, 0) → LINK: add link (M2M only)
// (5, 0, 0) → CLEAR: remove all links (M2M only)
// (6, 0, [ids]) → SET: replace all links (M2M only)
type Command struct {
Operation CommandOp
ID int64
Values Values
IDs []int64 // For SET command
}
// CommandOp is the command operation type.
type CommandOp int
const (
CommandCreate CommandOp = 0
CommandUpdate CommandOp = 1
CommandDelete CommandOp = 2
CommandUnlink CommandOp = 3
CommandLink CommandOp = 4
CommandClear CommandOp = 5
CommandSet CommandOp = 6
)
// CmdCreate returns a CREATE command. Mirrors: Command.create(values)
func CmdCreate(values Values) Command {
return Command{Operation: CommandCreate, Values: values}
}
// CmdUpdate returns an UPDATE command. Mirrors: Command.update(id, values)
func CmdUpdate(id int64, values Values) Command {
return Command{Operation: CommandUpdate, ID: id, Values: values}
}
// CmdDelete returns a DELETE command. Mirrors: Command.delete(id)
func CmdDelete(id int64) Command {
return Command{Operation: CommandDelete, ID: id}
}
// CmdUnlink returns an UNLINK command. Mirrors: Command.unlink(id)
func CmdUnlink(id int64) Command {
return Command{Operation: CommandUnlink, ID: id}
}
// CmdLink returns a LINK command. Mirrors: Command.link(id)
func CmdLink(id int64) Command {
return Command{Operation: CommandLink, ID: id}
}
// CmdClear returns a CLEAR command. Mirrors: Command.clear()
func CmdClear() Command {
return Command{Operation: CommandClear}
}
// CmdSet returns a SET command. Mirrors: Command.set(ids)
func CmdSet(ids []int64) Command {
return Command{Operation: CommandSet, IDs: ids}
}