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>
This commit is contained in:
Marc
2026-04-02 19:26:08 +02:00
parent 06e49c878a
commit b57176de2f
29 changed files with 3243 additions and 111 deletions

View File

@@ -0,0 +1,60 @@
package models
import "odoo-go/pkg/orm"
// initIrConfigParameter registers ir.config_parameter — System parameters.
// Mirrors: odoo/addons/base/models/ir_config_parameter.py class IrConfigParameter
//
// Key/value store for system-wide configuration.
// Examples: web.base.url, database.uuid, mail.catchall.domain
func initIrConfigParameter() {
m := orm.NewModel("ir.config_parameter", orm.ModelOpts{
Description: "System Parameter",
Order: "key",
RecName: "key",
})
m.AddFields(
orm.Char("key", orm.FieldOpts{String: "Key", Required: true, Index: true}),
orm.Text("value", orm.FieldOpts{String: "Value", Required: true}),
)
// get_param: returns the value for a key, or default.
// Mirrors: odoo/addons/base/models/ir_config_parameter.py IrConfigParameter.get_param()
m.RegisterMethod("get_param", func(rs *orm.Recordset, args ...interface{}) (interface{}, error) {
if len(args) == 0 {
return "", nil
}
key, _ := args[0].(string)
defaultVal := ""
if len(args) > 1 {
defaultVal, _ = args[1].(string)
}
env := rs.Env()
var value string
err := env.Tx().QueryRow(env.Ctx(),
`SELECT value FROM ir_config_parameter WHERE key = $1`, key).Scan(&value)
if err != nil {
return defaultVal, nil
}
return value, nil
})
// set_param: sets the value for a key (upsert).
// Mirrors: odoo/addons/base/models/ir_config_parameter.py IrConfigParameter.set_param()
m.RegisterMethod("set_param", func(rs *orm.Recordset, args ...interface{}) (interface{}, error) {
if len(args) < 2 {
return false, nil
}
key, _ := args[0].(string)
value, _ := args[1].(string)
env := rs.Env()
_, err := env.Tx().Exec(env.Ctx(),
`INSERT INTO ir_config_parameter (key, value) VALUES ($1, $2)
ON CONFLICT (key) DO UPDATE SET value = $2`, key, value)
if err != nil {
return false, err
}
return true, nil
})
}