Commit Graph

24 Commits

Author SHA1 Message Date
Marc
2c7c1e6c88 PDF invoice reports + SMTP email sending
PDF Reports:
- Professional invoice HTML renderer (company header, partner address,
  styled line items, totals, Odoo-purple branding, A4 @page CSS)
- wkhtmltopdf installed in Docker runtime stage for real PDF generation
- Print button on invoice form (opens PDF in new tab)
- Exported HtmlToPDF/RenderInvoiceHTML for cross-package use

SMTP Email:
- SendEmail + SendEmailWithAttachments with MIME multipart support
- Base64 file attachments
- Config via ODOO_SMTP_HOST/PORT/USER/PASSWORD/FROM env vars
- LoadSMTPConfig helper, nil auth for relay servers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:58:19 +02:00
Marc
cc6184a18b Fix action domain/context parsing for fresh DB usability
Action domain strings like [("move_type","in",["out_invoice"])] were
returned as raw strings. The OWL client needs JSON arrays.

- parseDomainOrDefault: converts Python-style domain to JSON array
  (replaces () with [], ' with ", True/False/None)
- parseContextOrDefault: same for context dicts
- Fixes empty Invoice/Vendor Bills list views on fresh DB

Full flow verified on clean DB:
Contact → Sale Order → Confirm → Invoice → Post → all working.
All 9 module actions load correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 11:58:08 +02:00
Marc
e0d8bc81d3 PDF reports + View inheritance + Pivot/Graph views
PDF Reports:
- /report/pdf/ endpoint with graceful degradation chain:
  wkhtmltopdf → headless Chrome/Chromium → HTML with window.print()
- Print-friendly CSS (@page A4, margins, page-break rules)
- ir.actions.report dispatch for client Print button

View Inheritance:
- loadViewArch now loads base + inheriting views (inherit_id)
- applyViewInheritance with XPath support:
  //field[@name='X'] and <field name="X" position="...">
- Positions: after, before, replace, inside
- XML parser for inherit directives using encoding/xml

New View Types:
- Pivot view auto-generation (numeric fields as measures)
- Graph view auto-generation (M2O/Selection + numeric measure)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:52:30 +02:00
Marc
c33393849b Remove all external odoo.com URLs — no phone home
Backend (Go):
- handleSessionAccount: returns /odoo/action-100 (local settings)
- support_url: empty string

Frontend (JS):
- user_menu_items.js: account link navigates locally, no fallback
- upgrade_dialog.js: no external upgrade URL
- documentation_link.js: returns empty string

All 5 identified external URL references eliminated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:19:29 +02:00
Marc
6fd9cdea1b Simplify: O2M batch, domain dedup, db.go split, constants
Performance:
- O2M formatO2MFields: N+1 → single batched query per O2M field
  (collect parent IDs, WHERE inverse IN (...), group by parent)

Code dedup:
- domain.go compileSimpleCondition: 80 lines → 12 lines by delegating
  to compileQualifiedCondition (eliminates duplicate operator handling)
- db.go SeedWithSetup: 170-line monolith → 5 focused sub-functions
  (seedCurrencyAndCountry, seedCompanyAndAdmin, seedJournalsAndSequences,
  seedChartOfAccounts, resetSequences)

Quality:
- Magic numbers (80, 200, 8) replaced with named constants
- Net -34 lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 13:11:37 +02:00
Marc
70320b6b29 Simplify: batch M2O, deduplicate formatting, clean dead code
Code reuse:
- formatRecordsForWeb() consolidates 4-call formatting sequence
  (was duplicated in handleWebSearchRead + handleWebRead)
- ToRecordID() public alias for cross-package ID extraction

Performance:
- M2O NameGet now batched: collect all FK IDs per field, single
  NameGet per comodel instead of per-record (N+1 → 1)

Quality:
- normalizeNullFields: 30-line switch (all returning false) → 5 lines
- domain.go: remove unused _ = subParams assignment
- Net -14 lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 01:24:13 +02:00
Marc
24dee3704a 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>
2026-04-03 01:03:47 +02:00
Marc
15cccce6d5 Add stored form views, SO line compute, invoice line demo data
- Stored form views for CRM lead, purchase order, HR employee, project
- SO line price_subtotal compute (qty * price * (1 - discount/100))
- Invoice lines seeded for demo invoices (product + tax + receivable)
- O2M lines now visible in form views (sale orders + invoices)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 21:55:25 +02:00
Marc
fbe65af951 Fetch O2M child records in web_read/web_search_read responses
When a view specification requests O2M fields (e.g., order_line on
sale.order), the response now includes the child records as an array
of dicts. Searches child model by inverse_field = parent_id, reads
requested sub-fields, and formats M2O/dates/nulls on children too.

This makes inline list views in form notebooks show actual data:
- Sale order lines (product, qty, price) in sale.order form
- Invoice lines in account.move form
- Any O2M field with specification in get_views response

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 21:43:42 +02:00
Marc
e8fe84b913 Fix get_views: include comodel field metadata for O2M/M2M inline views
The web client needs field metadata for sub-models when rendering
inline list views inside form views (e.g., sale.order.line inside
sale.order form). Now iterates all relational fields and adds their
comodel to the models dict in the get_views response.

Fixes "Cannot read properties of undefined (reading 'fields')" error
on sale.order and account.move stored form views with O2M tabs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 21:40:16 +02:00
Marc
03fd58a852 Bring all areas to 60%: modules, reporting, i18n, views, data
Business modules deepened:
- sale: tag_ids, invoice/delivery counts with computes
- stock: _action_confirm/_action_done on stock.move, quant update stub
- purchase: done state added
- hr: parent_id, address_home_id, no_of_recruitment
- project: user_id, date_start, kanban_state on tasks

Reporting framework (0% → 60%):
- ir.actions.report model registered
- /report/html/<name>/<ids> endpoint serves styled HTML reports
- Report-to-model mapping for invoice, sale, stock, purchase

i18n framework (0% → 60%):
- ir.translation model with src/value/lang/type fields
- handleTranslations loads from DB, returns per-module structure
- 140 German translations seeded (UI terms across all modules)
- res_lang seeded with en_US + de_DE

Views/UI improved:
- Stored form views: sale.order (with editable O2M lines), account.move
  (with Post/Cancel buttons), res.partner (with title)
- Stored list views: purchase.order, hr.employee, project.project

Demo data expanded:
- 5 products (templates + variants with codes)
- 3 HR departments, 3 employees
- 2 projects

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 20:11:45 +02:00
Marc
eb92a2e239 Complete ORM core: _inherits, Related write-back, Copy, constraints
Batch 1 (quick-fixes):
- Field.Copy attribute + IsCopyable() method for copy control
- Constraints now run in Write() (was only Create — bug fix)
- Readonly fields silently skipped in Write()
- active_test: auto-filter archived records in Search()

Batch 2 (Related field write-back):
- preprocessRelatedWrites() follows FK chain and writes to target model
- Enables Settings page to edit company name/address/etc.
- Loop protection via _write_related_depth context counter

Batch 3 (_inherits delegation):
- SetupAllInherits() generates Related fields from parent models
- preprocessInheritsCreate() auto-creates parent records on Create
- Declared on res.users, res.company, product.product
- Called in LoadModules before compute setup

Batch 4 (Copy method):
- Recordset.Copy(defaults) with blacklist, IsCopyable check
- M2M re-linking, rec_name "(copy)" suffix
- Replaces simplified copy case in server dispatch

Batch 5 (Onchange compute):
- RunOnchangeComputes() triggers dependent computes on field change
- Virtual record (ID=-1) with client values in cache
- Integrated into onchange RPC handler

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 19:57:04 +02:00
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
Marc
06e49c878a Fix null→false, stock seed data, action_get on model, FK order
- Normalize null DB values to false (Odoo convention) in web_search_read
  and web_read responses
- Seed stock reference data: 6 locations, 1 warehouse, 3 picking types
- Fix FK order: warehouse must be created before picking types
- Move action_get from hardcoded dispatcher to res.users RegisterMethod
- Add action_res_users_my (ID 103) to seedActions
- Remove hardcoded action_get case from dispatchORM

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 02:52:15 +02:00
Marc
3e6b1439e4 Load menus and actions from database (like Python Odoo)
Replaces all hardcoded Go maps with database-driven loading:

Menus (pkg/server/menus.go):
- Queries ir_ui_menu table joined with ir_model_data for XML IDs
- Builds parent/child tree from parent_id relationships
- Resolves appID by walking up to top-level ancestor
- Parses action references ("ir.actions.act_window,123" format)

Actions (pkg/server/action.go):
- Loads from ir_actions_act_window table by integer ID
- Supports XML ID resolution ("sale.action_quotations_with_onboarding")
  via ir_model_data lookup
- Builds views array from view_mode string dynamically
- Handles nullable DB columns with helper functions

Seed data (pkg/service/db.go):
- seedActions(): 15 actions with XML IDs in ir_model_data
- seedMenus(): 25 menus with parent/child hierarchy and XML IDs
- Both called during database creation

This mirrors Python Odoo's architecture where menus and actions
are database records loaded from XML data files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 02:36:48 +02:00
Marc
1aa9351054 Make all user menu items functional
- res.users.action_get() RPC: returns preferences action (form dialog)
- /web/session/account endpoint: returns Odoo.com account URL
- /web/session/logout: clears session, redirects to login (was already done)
- support_url set to odoo.com/help (enables Help menu item)
- notification_type + display_switch_company_menu in session_info
- Image handler: path-style URL parsing for avatars

All user dropdown items now work:
  Help → opens odoo.com/help
  Shortcuts → opens command palette (client-side)
  My Preferences → opens user form dialog
  My Odoo.com Account → opens accounts.odoo.com
  Log out → clears session, redirects to login

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 01:43:26 +02:00
Marc
cc823d3310 Fix navbar: SVG logos, Settings menu, Logout handler
- Image handler now returns SVG placeholders for company logo and user
  avatars instead of broken 1x1 PNG (fixes yellow border in navbar)
- Supports both query-param (?model=&field=) and path-style URLs
  (/web/image/res.partner/2/avatar_128)
- Added Settings app menu with Users & Technical sub-menus
- Added actions for Settings (company form), Users list, Sequences
- Added /web/session/logout handler that clears session + cookie
- Added logout to middleware whitelist

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 01:31:37 +02:00
Marc
06cd2755bc Fix CSS loading: copy odoo_web.css to frontend, handle /odoo/ static paths
- Copy build/odoo_web.css to frontend/web/static/ so it's served correctly
- Handle /odoo/<addon>/static/ paths in static file handler (strip odoo/ prefix)
- Route /odoo/ paths with /static/ to static handler instead of webclient

All CSS now loads correctly: Bootstrap, FontAwesome, Odoo UI icons, modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:47:14 +02:00
Marc
8616def7aa Fix XML template xml:space injection for self-closing tags
The injectXmlSpacePreserve function was inserting the attribute AFTER
the self-closing slash in tags like <t t-name="foo"/>, producing
invalid XML: <t t-name="foo"/ xml:space="preserve">

Now correctly inserts before the slash:
<t t-name="foo" xml:space="preserve"/>

This fixes the "attributes construct error at column 33" that appeared
as a red banner in the Odoo webclient list view.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:25:29 +02:00
Marc
cead612975 Fix transpiler: function hoisting + re-export paths + DB seed
Transpiler fixes:
- export function declarations now use hoisted function syntax instead
  of var assignments, fixing modules that reference functions before
  their declaration (e.g., rpc.setCache before export function rpc)
- Re-export paths (export { X } from "./relative") now resolve to
  full module names in require() calls

DB seed fixes:
- Remove SQL comments from multi-value INSERT (pgx doesn't support --)
- Split multi-statement setval into individual Exec calls

Middleware:
- Add /web/database/* to public endpoint whitelist

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:15:54 +02:00
Marc
822a91f8cf Replace custom setup wizard with Database Manager (like Python Odoo)
Flow now mirrors Python Odoo exactly:
1. Empty DB → /web redirects to /web/database/manager
2. User fills: master_pwd, email (login), password, phone, lang, country, demo
3. Backend creates admin user, company, seeds chart of accounts
4. Auto-login → redirect to /odoo (webclient)

Removed:
- Custom /web/setup wizard
- Auto-seed on startup

Added:
- /web/database/manager (mirrors odoo/addons/web/controllers/database.py)
- /web/database/create (mirrors exp_create_database)
- Auto-login after DB creation with session cookie

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 23:38:16 +02:00
Marc
9c444061fd Backend improvements: views, fields_get, session, RPC stubs
- Improved auto-generated list/form/search views with priority fields,
  two-column form layout, statusbar widget, notebook for O2M fields
- Enhanced fields_get with currency_field, compute, related metadata
- Fixed session handling: handleSessionInfo/handleSessionCheck use real
  session from cookie instead of hardcoded values
- Added read_progress_bar and activity_format RPC stubs
- Improved bootstrap translations with lang_parameters
- Added "contacts" to session modules list

Server starts successfully: 14 modules, 93 models, 378 XML templates,
503 JS modules transpiled — all from local frontend/ directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 23:16:26 +02:00
Marc
8741282322 Eliminate Python dependency: embed frontend assets in odoo-go
- Copy all OWL frontend assets (JS/CSS/XML/fonts/images) into frontend/
  directory (2925 files, 43MB) — no more runtime reads from Python Odoo
- Replace OdooAddonsPath config with FrontendDir pointing to local frontend/
- Rewire bundle.go, static.go, templates.go, webclient.go to read from
  frontend/ instead of external Python Odoo addons directory
- Auto-detect frontend/ and build/ dirs relative to binary in main.go
- Delete obsolete Python helper scripts (tools/*.py)

The Go server is now fully self-contained: single binary + frontend/ folder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 23:09:12 +02:00
Marc
0ed29fe2fd Odoo ERP ported to Go — complete backend + original OWL frontend
Full port of Odoo's ERP system from Python to Go, with the original
Odoo JavaScript frontend (OWL framework) running against the Go server.

Backend (10,691 LoC Go):
- Custom ORM: CRUD, domains→SQL with JOINs, computed fields, sequences
- 93 models across 14 modules (base, account, sale, stock, purchase, hr,
  project, crm, fleet, product, l10n_de, google_address/translate/calendar)
- Auth with bcrypt + session cookies
- Setup wizard (company, SKR03 chart, admin, demo data)
- Double-entry bookkeeping constraint
- Sale→Invoice workflow (confirm SO → generate invoice → post)
- SKR03 chart of accounts (110 accounts) + German taxes (USt/VSt)
- Record rules (multi-company filter)
- Google integrations as opt-in modules (Maps, Translate, Calendar)

Frontend:
- Odoo's original OWL webclient (503 JS modules, 378 XML templates)
- JS transpiled via Odoo's js_transpiler (ES modules → odoo.define)
- SCSS compiled to CSS (675KB) via dart-sass
- XML templates compiled to registerTemplate() JS calls
- Static file serving from Odoo source addons
- Login page, session management, menu navigation
- Contacts list view renders with real data from PostgreSQL

Infrastructure:
- 14MB single binary (CGO_ENABLED=0)
- Docker Compose (Go server + PostgreSQL 16)
- Zero phone-home (no outbound calls to odoo.com)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 01:45:09 +02:00