Complete ORM gaps + server features + module depth push

ORM:
- SQL Constraints support (Model.AddSQLConstraint, applied in InitDatabase)
- Translatable field Read (ir_translation lookup for non-en_US)
- active_test filter in SearchCount + ReadGroup (consistency with Search)
- Environment.Ref() improved (format validation, parameterized query)

Server:
- /web/action/run endpoint (server action execution stub)
- /web/model/get_definitions (field metadata for multiple models)
- Binary field serving rewritten: reads from DB, falls back to SVG
  with record initial (fixes avatar/logo rendering)

Business modules deepened:
- Account: action_post validation (partner, lines), sequence numbering
  (JOURNAL/YYYY/NNNN), action_register_payment, remove_move_reconcile
- Sale: action_cancel, action_draft, action_view_invoice
- Purchase: button_draft
- Stock: action_cancel on picking
- CRM: action_set_won_rainbowman, convert_opportunity
- HR: hr.contract model (employee, wage, dates, state)
- Project: action_blocked, task stage seed data

Views:
- Cancel/Reset buttons in sale.form header
- Register Payment button in invoice.form (visible when posted+unpaid)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc
2026-04-03 01:03:47 +02:00
parent cc1f150732
commit 24dee3704a
9 changed files with 255 additions and 46 deletions

View File

@@ -1,12 +1,38 @@
package server
import (
"encoding/json"
"fmt"
"net/http"
"strings"
"odoo-go/pkg/orm"
)
// handleGetDefinitions returns field definitions for one or more models.
// Mirrors: odoo/addons/web/controllers/model.py Model.get_definitions()
func (s *Server) handleGetDefinitions(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
var req JSONRPCRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
s.writeJSONRPC(w, nil, nil, &RPCError{Code: -32700, Message: "Parse error"})
return
}
var params struct {
Models []string `json:"model_names"`
}
json.Unmarshal(req.Params, &params)
result := make(map[string]interface{})
for _, modelName := range params.Models {
result[modelName] = fieldsGetForModel(modelName)
}
s.writeJSONRPC(w, req.ID, result, nil)
}
// handleGetViews implements the get_views method.
// Mirrors: odoo/addons/base/models/ir_ui_view.py get_views()
func handleGetViews(env *orm.Environment, model string, params CallKWParams) (interface{}, *RPCError) {