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

@@ -322,7 +322,34 @@ func initSaleOrder() {
`UPDATE sale_order SET invoice_status = 'invoiced' WHERE id = $1`, soID)
}
return invoiceIDs, nil
if len(invoiceIDs) == 0 {
return false, nil
}
// Return action to open the created invoice(s)
// Mirrors: odoo/addons/sale/models/sale_order.py action_view_invoice()
if len(invoiceIDs) == 1 {
return map[string]interface{}{
"type": "ir.actions.act_window",
"res_model": "account.move",
"res_id": invoiceIDs[0],
"view_mode": "form",
"views": [][]interface{}{{nil, "form"}},
"target": "current",
}, nil
}
// Multiple invoices → list view
ids := make([]interface{}, len(invoiceIDs))
for i, id := range invoiceIDs {
ids[i] = id
}
return map[string]interface{}{
"type": "ir.actions.act_window",
"res_model": "account.move",
"view_mode": "list,form",
"views": [][]interface{}{{nil, "list"}, {nil, "form"}},
"domain": []interface{}{[]interface{}{"id", "in", ids}},
"target": "current",
}, nil
})
// action_create_delivery: Generate a stock picking (delivery) from a confirmed sale order.
@@ -437,6 +464,54 @@ func initSaleOrderLine() {
Order: "order_id, sequence, id",
})
// -- Onchange: product_id → name + price_unit --
// Mirrors: odoo/addons/sale/models/sale_order_line.py _compute_name(), _compute_price_unit()
// When the user selects a product on a SO line, automatically fill in the
// description from the product name and the unit price from the product list price.
m.RegisterOnchange("product_id", func(env *orm.Environment, vals orm.Values) orm.Values {
result := make(orm.Values)
// Extract product_id — may arrive as int64, int32, float64, or map with "id" key
var productID int64
switch v := vals["product_id"].(type) {
case int64:
productID = v
case int32:
productID = int64(v)
case float64:
productID = int64(v)
case map[string]interface{}:
if id, ok := v["id"]; ok {
switch n := id.(type) {
case float64:
productID = int64(n)
case int64:
productID = n
}
}
}
if productID <= 0 {
return result
}
// Read product name and list price
var name string
var listPrice float64
err := env.Tx().QueryRow(env.Ctx(),
`SELECT COALESCE(pt.name, ''), COALESCE(pt.list_price, 0)
FROM product_product pp
JOIN product_template pt ON pt.id = pp.product_tmpl_id
WHERE pp.id = $1`, productID,
).Scan(&name, &listPrice)
if err != nil {
return result
}
result["name"] = name
result["price_unit"] = listPrice
return result
})
// -- Parent --
m.AddFields(
orm.Many2one("order_id", "sale.order", orm.FieldOpts{