Files
goodie/addons/base/models/res_config_settings.go
Marc b57176de2f Bring odoo-go to ~70%: read_group, record rules, admin, sessions
Phase 1: read_group/web_read_group with SQL GROUP BY, aggregates
  (sum/avg/min/max/count/array_agg/sum_currency), date granularity,
  M2O groupby resolution to [id, display_name].

Phase 2: Record rules with domain_force parsing (Python literal parser),
  global AND + group OR merging. Domain operators: child_of, parent_of,
  any, not any compiled to SQL hierarchy/EXISTS queries.

Phase 3: Button dispatch via /web/dataset/call_button, method return
  values interpreted as actions. Payment register wizard
  (account.payment.register) for sale→invoice→pay flow.

Phase 4: ir.filters, ir.default, product fields expanded, SO line
  product_id onchange, ir_model+ir_model_fields DB seeding.

Phase 5: CSV export (/web/export/csv), attachment upload/download
  via ir.attachment, fields_get with aggregator hints.

Admin/System: Session persistence (PostgreSQL-backed), ir.config_parameter
  with get_param/set_param, ir.cron, ir.logging, res.lang, res.config.settings
  with company-related fields, Settings form view. Technical menu with
  Views/Actions/Parameters/Security/Logging sub-menus. User change_password,
  preferences. Password never exposed in UI/API.

Bugfixes: false→nil for varchar/int fields, int32 in toInt64, call_button
  route with trailing slash, create_invoices returns action, search view
  always included, get_formview_action, name_create, ir.http stub.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 19:26:08 +02:00

77 lines
3.6 KiB
Go

package models
import "odoo-go/pkg/orm"
// initResConfigSettings registers the res.config.settings transient model.
// Mirrors: odoo/addons/base/models/res_config.py class ResConfigSettings(TransientModel)
//
// This wizard provides the Settings form. Each "save" creates a new transient
// record, applies the values, then the record is eventually cleaned up.
func initResConfigSettings() {
m := orm.NewModel("res.config.settings", orm.ModelOpts{
Description: "Config Settings",
Type: orm.ModelTransient,
})
// -- General settings --
m.AddFields(
orm.Many2one("company_id", "res.company", orm.FieldOpts{
String: "Company", Index: true,
}),
orm.Boolean("user_default_rights", orm.FieldOpts{String: "Default Access Rights"}),
orm.Boolean("external_email_server_default", orm.FieldOpts{String: "External Email Servers"}),
orm.Boolean("module_base_import", orm.FieldOpts{String: "Allow Import"}),
orm.Boolean("module_google_calendar", orm.FieldOpts{String: "Google Calendar"}),
orm.Boolean("group_multi_company", orm.FieldOpts{String: "Multi Companies"}),
orm.Boolean("show_effect", orm.FieldOpts{String: "Show Effect", Default: true}),
)
// -- Company info fields (mirrors res.company, for display in settings) --
// Mirrors: odoo/addons/base/models/res_config_settings.py company-related fields
m.AddFields(
orm.Char("company_name", orm.FieldOpts{String: "Company Name", Related: "company_id.name"}),
orm.Many2one("company_currency_id", "res.currency", orm.FieldOpts{
String: "Currency", Related: "company_id.currency_id",
}),
orm.Many2one("company_country_id", "res.country", orm.FieldOpts{
String: "Country", Related: "company_id.country_id",
}),
orm.Char("company_street", orm.FieldOpts{String: "Street", Related: "company_id.street"}),
orm.Char("company_street2", orm.FieldOpts{String: "Street2", Related: "company_id.street2"}),
orm.Char("company_zip", orm.FieldOpts{String: "Zip", Related: "company_id.zip"}),
orm.Char("company_city", orm.FieldOpts{String: "City", Related: "company_id.city"}),
orm.Char("company_phone", orm.FieldOpts{String: "Phone", Related: "company_id.phone"}),
orm.Char("company_email", orm.FieldOpts{String: "Email", Related: "company_id.email"}),
orm.Char("company_website", orm.FieldOpts{String: "Website", Related: "company_id.website"}),
orm.Char("company_vat", orm.FieldOpts{String: "Tax ID", Related: "company_id.vat"}),
orm.Char("company_registry", orm.FieldOpts{String: "Company Registry", Related: "company_id.company_registry"}),
)
// -- Accounting settings --
m.AddFields(
orm.Char("chart_template", orm.FieldOpts{String: "Chart of Accounts"}),
orm.Selection("tax_calculation_rounding_method", []orm.SelectionItem{
{Value: "round_per_line", Label: "Round per Line"},
{Value: "round_globally", Label: "Round Globally"},
}, orm.FieldOpts{String: "Tax Calculation Rounding Method", Default: "round_per_line"}),
)
// execute: called by the Settings form to apply configuration.
// Mirrors: odoo/addons/base/models/res_config.py ResConfigSettings.execute()
m.RegisterMethod("execute", func(rs *orm.Recordset, args ...interface{}) (interface{}, error) {
// In Python Odoo this writes Related fields back to res.company.
// For now we just return true; the Related fields are read-only display.
return true, nil
})
// DefaultGet: pre-fill from current company.
// Mirrors: odoo/addons/base/models/res_config.py ResConfigSettings.default_get()
m.DefaultGet = func(env *orm.Environment, fields []string) orm.Values {
vals := orm.Values{
"company_id": env.CompanyID(),
"show_effect": true,
}
return vals
}
}