Skip to content

Fix local mode with Odoo 11 to 20 - #63

Merged
florentx merged 3 commits into
masterfrom
fix/local-mode
Nov 27, 2026
Merged

florentx merged 3 commits into
masterfrom
fix/local-mode

Conversation

@florentx

Copy link
Copy Markdown
Member

Local mode (scheme = local, or odooly -c odoo.conf) had several bugs in 3.x, and didn't work at all with Odoo 19. This PR fixes it, and tests it with Odoo 11 and later.

  • Odoo 19: import odoo no longer loads the sub-packages. odooly now imports odoo.http, which runs odoo.init (core setup and monkey patches).
  • Odoo 20: dispatch_rpc moved to odoo.http.router, and the db service was removed. Database management is rebuilt on odoo.modules.db. The user context is now a read-only mapping.
  • Databases: since 3.0, client.database only existed for Web servers. Database list, selection, create, clone and drop now use the db service.
  • Command line: -c odoo.conf and scheme = local environments crashed, and PGAPPNAME was client.py instead of odooly.
  • Clear errors for features that need a Webclient session: Superuser, session_authenticate(), render_pdf().
  • from_config() switches back to the environment's database when the client is reused.
  • with_odoo() crashed for a Record and for a lazy RecordList.

Local mode needs Odoo 11.0 or later: Odoo 9 and 10 run only on Python 2.

Testing

  • New tests/test_local.py, with a fake odoo package for Odoo 11, 12, 18, 19 and 20, including each version's db service signatures.
  • Checked by hand against real servers in Docker: Odoo 11.0 on Python 3.8, OCA/OCB 12.0, Odoo 18 and 19, and upstream Odoo 20.0.
  • Each commit passes the test suite with both HTTP backends.

🤖 Co-authored with Claude Code

Odoo browse() needs plain integers, and a lazy search is executed
first.  Add tests for Env.cr, Env.odoo_env and with_odoo() in local
mode, and check they are not available otherwise.
- Odoo 19: import odoo.http, which imports odoo.init (core setup),
  the registry and the services
- database list, selection, create/clone/drop with the 'db' service
  (client.database was only available for Web servers since 3.0)
- CLI: option -c passes a str to Odoo, and 'scheme = local'
  environments can be cached and reused; PGAPPNAME=odooly
- clear errors for Webclient-only features: Superuser,
  session_authenticate() and render_pdf()
- from_config() switches back to the database of the environment
- tests: fake odoo package for 18 and 19
Odoo 20 moved dispatch_rpc to odoo.http.router and removed the 'db'
service: database management is rebuilt on odoo.modules.db.  The
dispatcher is kept as odoo._dispatch_rpc, instead of patching odoo.http.
The user context is a read-only mapping in local mode.

Tests for Odoo 11, 12 and 20: check the signatures of the 'db' service
per version ('phone' since 12.0, 'neutralize_database' since 16.0), and
Environment.reset() before 15.0.
@florentx
florentx merged commit 2347446 into master Nov 27, 2026
12 checks passed
@florentx
florentx deleted the fix/local-mode branch November 27, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant