Files
silo/internal/odoo/client.go
Forbes 7550b78740 feat: Infor-style split-panel layout, projects page, fuzzy search, Odoo scaffold
Web UI - Infor CloudSuite-style split-panel layout (items.html rewrite):
- Replace modal-based item detail with inline split-panel workspace
- Horizontal mode: item list on left, tabbed detail panel on right
- Vertical mode: detail panel on top, item list below
- Detail tabs: Main, Properties, Revisions, BOM, Where Used
- Ctrl+F opens in-page filter overlay with fuzzy search
- Column config gear icon with per-layout-mode persistence
- Search scope toggle pills (All / Part Number / Description)
- Selected row highlight with accent border
- Responsive breakpoint forces vertical below 900px
- Create/Edit/Delete remain as modal dialogs

Web UI - Projects page:
- New projects.html template with full CRUD
- Project table: Code, Name, Description, Item count, Created, Actions
- Create/Edit/Delete modals
- Click project code navigates to items filtered by project
- 3-tab navigation in base.html: Items, Projects, Schemas

Fuzzy search:
- Add sahilm/fuzzy dependency for ranked text matching
- New internal/api/search.go with SearchableItems fuzzy.Source
- GET /api/items/search endpoint with field scope and type/project filters
- Frontend routes to fuzzy endpoint when search input is non-empty

Odoo ERP integration scaffold:
- Migration 008: integrations and sync_log tables
- internal/odoo/ package: types, client stubs, sync stubs
- internal/db/integrations.go: IntegrationRepository
- internal/config/config.go: OdooConfig struct
- 6 API endpoints for config CRUD, sync log, test, push, pull
- All sync operations return stub responses

Documentation:
- docs/REPOSITORY_STATUS.md: comprehensive repository state report
  with architecture overview, API surface, feature stubs, and
  potential issues analysis
2026-01-31 09:20:27 -06:00

76 lines
2.2 KiB
Go

package odoo
import (
"context"
"fmt"
"net/http"
"github.com/rs/zerolog"
)
// Client provides access to the Odoo JSON-RPC API.
type Client struct {
config Config
http *http.Client
logger zerolog.Logger
uid int
}
// NewClient creates a new Odoo API client.
func NewClient(cfg Config, logger zerolog.Logger) *Client {
return &Client{
config: cfg,
http: &http.Client{},
logger: logger.With().Str("component", "odoo-client").Logger(),
}
}
// Authenticate authenticates with the Odoo server and stores the user ID.
func (c *Client) Authenticate(_ context.Context) error {
// TODO: Implement JSON-RPC call to /web/session/authenticate
c.logger.Info().
Str("url", c.config.URL).
Str("database", c.config.Database).
Str("username", c.config.Username).
Msg("odoo authenticate stub called")
return fmt.Errorf("odoo authentication not yet implemented")
}
// SearchRead queries records from an Odoo model.
func (c *Client) SearchRead(_ context.Context, model string, domain []any, fields []string, limit int) ([]map[string]any, error) {
// TODO: Implement JSON-RPC call to /web/dataset/call_kw
c.logger.Info().
Str("model", model).
Int("limit", limit).
Msg("odoo search_read stub called")
return nil, fmt.Errorf("odoo search_read not yet implemented")
}
// Create creates a new record in an Odoo model.
func (c *Client) Create(_ context.Context, model string, values map[string]any) (int, error) {
// TODO: Implement JSON-RPC call to create
c.logger.Info().
Str("model", model).
Msg("odoo create stub called")
return 0, fmt.Errorf("odoo create not yet implemented")
}
// Write updates an existing record in an Odoo model.
func (c *Client) Write(_ context.Context, model string, id int, values map[string]any) error {
// TODO: Implement JSON-RPC call to write
c.logger.Info().
Str("model", model).
Int("id", id).
Msg("odoo write stub called")
return fmt.Errorf("odoo write not yet implemented")
}
// TestConnection verifies the Odoo connection is working.
func (c *Client) TestConnection(_ context.Context) error {
// TODO: Attempt authentication and return result
c.logger.Info().
Str("url", c.config.URL).
Msg("odoo test_connection stub called")
return fmt.Errorf("odoo test connection not yet implemented")
}