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>
This commit is contained in:
131
addons/crm/models/crm.go
Normal file
131
addons/crm/models/crm.go
Normal file
@@ -0,0 +1,131 @@
|
||||
package models
|
||||
|
||||
import "odoo-go/pkg/orm"
|
||||
|
||||
// initCRMLead registers the crm.lead model.
|
||||
// Mirrors: odoo/addons/crm/models/crm_lead.py
|
||||
func initCRMLead() {
|
||||
m := orm.NewModel("crm.lead", orm.ModelOpts{
|
||||
Description: "Lead/Opportunity",
|
||||
Order: "priority desc, id desc",
|
||||
RecName: "name",
|
||||
})
|
||||
|
||||
m.AddFields(
|
||||
orm.Char("name", orm.FieldOpts{String: "Opportunity", Required: true, Index: true}),
|
||||
orm.Selection("type", []orm.SelectionItem{
|
||||
{Value: "lead", Label: "Lead"},
|
||||
{Value: "opportunity", Label: "Opportunity"},
|
||||
}, orm.FieldOpts{String: "Type", Required: true, Default: "lead", Index: true}),
|
||||
orm.Many2one("partner_id", "res.partner", orm.FieldOpts{String: "Customer", Index: true}),
|
||||
orm.Char("partner_name", orm.FieldOpts{String: "Company Name"}),
|
||||
orm.Char("email_from", orm.FieldOpts{String: "Email", Index: true}),
|
||||
orm.Char("phone", orm.FieldOpts{String: "Phone"}),
|
||||
orm.Char("website", orm.FieldOpts{String: "Website"}),
|
||||
orm.Char("function", orm.FieldOpts{String: "Job Position"}),
|
||||
orm.Selection("state", []orm.SelectionItem{
|
||||
{Value: "open", Label: "Open"},
|
||||
{Value: "won", Label: "Won"},
|
||||
{Value: "lost", Label: "Lost"},
|
||||
}, orm.FieldOpts{String: "Status", Default: "open"}),
|
||||
orm.Many2one("stage_id", "crm.stage", orm.FieldOpts{String: "Stage", Index: true}),
|
||||
orm.Many2one("user_id", "res.users", orm.FieldOpts{String: "Salesperson", Index: true}),
|
||||
orm.Many2one("team_id", "crm.team", orm.FieldOpts{String: "Sales Team", Index: true}),
|
||||
orm.Monetary("expected_revenue", orm.FieldOpts{
|
||||
String: "Expected Revenue", CurrencyField: "currency_id",
|
||||
}),
|
||||
orm.Monetary("recurring_revenue", orm.FieldOpts{
|
||||
String: "Recurring Revenue", CurrencyField: "currency_id",
|
||||
}),
|
||||
orm.Selection("recurring_plan", []orm.SelectionItem{
|
||||
{Value: "monthly", Label: "Monthly"},
|
||||
{Value: "quarterly", Label: "Quarterly"},
|
||||
{Value: "yearly", Label: "Yearly"},
|
||||
}, orm.FieldOpts{String: "Recurring Plan"}),
|
||||
orm.Date("date_deadline", orm.FieldOpts{String: "Expected Closing"}),
|
||||
orm.Datetime("date_last_stage_update", orm.FieldOpts{String: "Last Stage Update"}),
|
||||
orm.Selection("priority", []orm.SelectionItem{
|
||||
{Value: "0", Label: "Normal"},
|
||||
{Value: "1", Label: "Low"},
|
||||
{Value: "2", Label: "High"},
|
||||
{Value: "3", Label: "Very High"},
|
||||
}, orm.FieldOpts{String: "Priority", Default: "0"}),
|
||||
orm.Integer("color", orm.FieldOpts{String: "Color Index"}),
|
||||
orm.Many2many("tag_ids", "crm.tag", orm.FieldOpts{String: "Tags"}),
|
||||
orm.Many2one("company_id", "res.company", orm.FieldOpts{
|
||||
String: "Company", Required: true, Index: true,
|
||||
}),
|
||||
orm.Many2one("currency_id", "res.currency", orm.FieldOpts{String: "Currency"}),
|
||||
orm.Float("probability", orm.FieldOpts{String: "Probability (%)"}),
|
||||
orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
|
||||
orm.Text("description", orm.FieldOpts{String: "Notes"}),
|
||||
orm.Many2one("lost_reason_id", "crm.lost.reason", orm.FieldOpts{String: "Lost Reason"}),
|
||||
// Address fields
|
||||
orm.Char("city", orm.FieldOpts{String: "City"}),
|
||||
orm.Char("street", orm.FieldOpts{String: "Street"}),
|
||||
orm.Char("zip", orm.FieldOpts{String: "Zip"}),
|
||||
orm.Many2one("country_id", "res.country", orm.FieldOpts{String: "Country"}),
|
||||
)
|
||||
}
|
||||
|
||||
// initCRMStage registers the crm.stage model.
|
||||
// Mirrors: odoo/addons/crm/models/crm_stage.py
|
||||
func initCRMStage() {
|
||||
m := orm.NewModel("crm.stage", orm.ModelOpts{
|
||||
Description: "CRM Stage",
|
||||
Order: "sequence, name, id",
|
||||
})
|
||||
|
||||
m.AddFields(
|
||||
orm.Char("name", orm.FieldOpts{String: "Stage Name", Required: true, Translate: true}),
|
||||
orm.Integer("sequence", orm.FieldOpts{String: "Sequence", Default: 1}),
|
||||
orm.Boolean("fold", orm.FieldOpts{String: "Folded in Pipeline"}),
|
||||
orm.Boolean("is_won", orm.FieldOpts{String: "Is Won Stage"}),
|
||||
orm.Many2many("team_ids", "crm.team", orm.FieldOpts{String: "Sales Teams"}),
|
||||
orm.Text("requirements", orm.FieldOpts{String: "Requirements"}),
|
||||
)
|
||||
}
|
||||
|
||||
// initCRMTeam registers the crm.team model.
|
||||
// Mirrors: odoo/addons/crm/models/crm_team.py
|
||||
func initCRMTeam() {
|
||||
m := orm.NewModel("crm.team", orm.ModelOpts{
|
||||
Description: "Sales Team",
|
||||
Order: "sequence, name",
|
||||
})
|
||||
|
||||
m.AddFields(
|
||||
orm.Char("name", orm.FieldOpts{String: "Sales Team", Required: true, Translate: true}),
|
||||
orm.Integer("sequence", orm.FieldOpts{String: "Sequence", Default: 10}),
|
||||
orm.Many2one("company_id", "res.company", orm.FieldOpts{
|
||||
String: "Company", Index: true,
|
||||
}),
|
||||
orm.Many2many("member_ids", "res.users", orm.FieldOpts{String: "Channel Members"}),
|
||||
orm.Integer("color", orm.FieldOpts{String: "Color Index"}),
|
||||
orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
|
||||
)
|
||||
}
|
||||
|
||||
// initCRMTag registers the crm.tag model.
|
||||
// Mirrors: odoo/addons/crm/models/crm_lead.py CrmTag
|
||||
func initCRMTag() {
|
||||
orm.NewModel("crm.tag", orm.ModelOpts{
|
||||
Description: "CRM Tag",
|
||||
Order: "name",
|
||||
}).AddFields(
|
||||
orm.Char("name", orm.FieldOpts{String: "Tag Name", Required: true, Translate: true}),
|
||||
orm.Integer("color", orm.FieldOpts{String: "Color Index"}),
|
||||
)
|
||||
}
|
||||
|
||||
// initCRMLostReason registers the crm.lost.reason model.
|
||||
// Mirrors: odoo/addons/crm/models/crm_lost_reason.py
|
||||
func initCRMLostReason() {
|
||||
orm.NewModel("crm.lost.reason", orm.ModelOpts{
|
||||
Description: "Opp. Lost Reason",
|
||||
Order: "name",
|
||||
}).AddFields(
|
||||
orm.Char("name", orm.FieldOpts{String: "Description", Required: true, Translate: true}),
|
||||
orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user