Files
goodie/addons/base/models/res_company.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

72 lines
2.6 KiB
Go

package models
import "odoo-go/pkg/orm"
// initResCompany registers the res.company model.
// Mirrors: odoo/addons/base/models/res_company.py class Company
//
// In Odoo, companies are central to multi-company support.
// Every record can be scoped to a company via company_id.
func initResCompany() {
m := orm.NewModel("res.company", orm.ModelOpts{
Description: "Companies",
Order: "sequence, name",
})
// -- Identity --
m.AddFields(
orm.Char("name", orm.FieldOpts{String: "Company Name", Required: true}),
orm.Integer("sequence", orm.FieldOpts{String: "Sequence", Default: 10}),
orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
orm.Many2one("parent_id", "res.company", orm.FieldOpts{String: "Parent Company"}),
orm.One2many("child_ids", "res.company", "parent_id", orm.FieldOpts{String: "Child Companies"}),
)
// -- Contact (delegates to partner) --
// In Odoo: _inherits = {'res.partner': 'partner_id'}
// We use explicit fields instead of delegation for clarity.
m.AddFields(
orm.Many2one("partner_id", "res.partner", orm.FieldOpts{
String: "Partner", Required: true, OnDelete: orm.OnDeleteRestrict,
}),
orm.Char("street", orm.FieldOpts{String: "Street"}),
orm.Char("street2", orm.FieldOpts{String: "Street2"}),
orm.Char("zip", orm.FieldOpts{String: "Zip"}),
orm.Char("city", orm.FieldOpts{String: "City"}),
orm.Many2one("state_id", "res.country.state", orm.FieldOpts{String: "State"}),
orm.Many2one("country_id", "res.country", orm.FieldOpts{String: "Country"}),
orm.Char("email", orm.FieldOpts{String: "Email"}),
orm.Char("phone", orm.FieldOpts{String: "Phone"}),
orm.Char("mobile", orm.FieldOpts{String: "Mobile"}),
orm.Char("website", orm.FieldOpts{String: "Website"}),
orm.Char("vat", orm.FieldOpts{String: "Tax ID"}),
orm.Char("company_registry", orm.FieldOpts{String: "Company ID (Registry)"}),
)
// -- Currency --
m.AddFields(
orm.Many2one("currency_id", "res.currency", orm.FieldOpts{
String: "Currency", Required: true,
}),
)
// -- Display --
m.AddFields(
orm.Binary("logo", orm.FieldOpts{String: "Company Logo"}),
orm.Char("color", orm.FieldOpts{String: "Color"}),
orm.Integer("font_color", orm.FieldOpts{String: "Font Color"}),
)
// -- Report Layout --
m.AddFields(
orm.Many2one("paperformat_id", "report.paperformat", orm.FieldOpts{String: "Paper Format"}),
orm.HTML("report_header", orm.FieldOpts{String: "Company Tagline"}),
orm.HTML("report_footer", orm.FieldOpts{String: "Report Footer"}),
)
// -- Fiscal --
m.AddFields(
orm.Many2one("account_fiscal_country_id", "res.country", orm.FieldOpts{String: "Fiscal Country"}),
)
}