You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow draft manual journal entries to be created through preview_write -> validate_write -> execute_approved_write with validated new journal items, despite Odoo's UI-readonly metadata. Support single and atomic batch creates without merging distinct items on the same account.
Note: Compatibility with #78 (ir.attachment resource linking) has been reconciled on #78's branch — see the comment below for integration details.
Reproduction and cause
On Odoo 16, preview and then validate this shape using valid journal/account IDs:
The existing validator rejects line_ids and move_type as readonly, even though Odoo's ORM supports this atomic draft creation. The flag describes UI behavior rather than an absolute ORM create prohibition. In the tested Odoo 17–19 images, line_ids is writable but move_type remains readonly, so explicit move_type="entry" also needs the narrow exception.
Changes and scope
Limit the readonly exception to line_ids and move_type on account.move creates whose effective type/state are entry/draft. Explicit values take precedence over context defaults.
Require the parent relation to be a one2many to account.move.line and fetch live child metadata from the same resolved instance.
Validate every line against that metadata, including when the parent relation is UI-writable. Accept only nonempty new-item [0, 0, values] commands; reject unknown/readonly line fields, explicit move_id, and nested one2many/many2many mutations.
Reject context.default_line_ids and disabling check_move_validity for this creation contract.
Preserve canonical payloads, approval tokens, command order, and distinct same-account items for both values and values_list.
Add 54 journal-entry regression test cases and a disposable accounting smoke script using the existing Compose/MCP helpers, covering real single and batch creates on XML-RPC and JSON-2.
Document the contract, posting, supported transports, verified compatibility, and reconciliation serialization limitation in README.md, docs/, and the Unreleased CHANGELOG.md section.
Preserved gates and Odoo accounting checks
The existing write approval workflow is preserved: live metadata, validation in the same server session, a matching payload and token, approval expiry, explicit confirmation, and enabled writes. Client-supplied metadata cannot authorize execution. Direct create, write, and unlink remain blocked in execute_method; field access controls and side-effect method policies are unchanged.
Validation checks metadata and command structure, not a simulated accounting transaction. Odoo remains responsible for ACLs, record rules, company/journal/account compatibility, currencies, rounding, and balance. A failed single create or batch create rolls back its moves and items atomically. action_post remains a separate transaction under the existing side-effect method policy.
Verified compatibility
Official disposable Odoo Community Docker images; Python 3.12.12; package version unchanged at 1.3.2.
Odoo
Odoo transport
Accounting over MCP stdio: single
Accounting over MCP stdio: batch
General MCP stdio
General Streamable HTTP
Inspector
16.0
XML-RPC
Passed
Passed
Passed
Not run
stdio passed
17.0
XML-RPC
Passed
Passed
Passed
Not run
stdio passed
18.0
XML-RPC
Passed
Passed
Passed
Not run
stdio passed
19.0
XML-RPC
Passed
Passed
Passed
Not run
Not run on this backend
19.0
JSON-2
Passed
Passed
Passed
Passed
stdio and HTTP passed
All 10 accounting scenarios verify the approval workflow, live metadata, unchanged payloads and tokens, distinct same-account items, posting, rollback on imbalance, and independent reconciliation. Batch tests also verify that an unbalanced second entry rolls back the whole batch and that reconciling one entry leaves the other untouched. Invalid fields, commands, and context values are rejected; missing validation, missing confirmation, tampered approvals, and direct creation are blocked.
The general smoke suite also verifies direct transport access, read/diagnostic tools, disabled standard writes, restricted-user access, complex record rules, packaged addon install/update, and locale plumbing.
Verification commands and results
uv sync --python 3.12 --extra dev
uv run python -m ruff check .
uv run python -m mypy src
uv run python -m pytest
PYTHONPATH=src uv run --with import-linter lint-imports
git diff --check
uv run --python 3.12 --with-editable . scripts/odoo_journal_entry_smoke.py \
--versions 16.0 17.0 18.0 19.0 --timeout 360
uv run --python 3.12 --with-editable . scripts/odoo_compose_smoke.py \
--versions 16.0 17.0 18.0 19.0 --timeout 360 --inspector-smoke
Ruff, mypy (34 source files), and whitespace checks: passed.
Pytest: 985 passed, including 54 journal-entry cases; one existing runpy warning in the CLI entrypoint test.
General smoke: 4 versions passed, 0 failures, including Odoo 19 JSON-2/Streamable HTTP and MCP Inspector.
Limits
On Odoo 16 XML-RPC, account.move.line.reconcile commits successfully but its recordset-valued response fails serialization. Both accounting scenarios confirm the committed outcome by readback without retrying the operation. This PR does not fix that separate serialization issue.
Accounting writes themselves are verified over MCP stdio; Streamable HTTP coverage is provided by the general smoke suite on Odoo 19 JSON-2.
Enterprise modules, custom addons, and additional accounting localizations are outside this test matrix. Odoo remains authoritative for their defaults and constraints.
Compatibility with #78 has been reconciled and pushed to #78's branch at 76928e2 (this PR's head and both base branches remain unchanged).
Because the original heads (e38e11d and 028f173) conflict in src/odoo_mcp/agent_tools.py and CHANGELOG.md, #78 now merges both branches (8b561eb) and adds nine cross-contract regression tests plus an accounting smoke check that links an attachment to the newly created move in the same MCP session.
The shared readonly_allowed_fields parameter is recomputed per entry and selected by mutually exclusive model/operation guards. The account.move create-only entry/draft contract, trusted live child metadata, attachment create/write explicit resource pair, approval/token/TTL/confirmation/write-enable gates, and Odoo ACLs/record rules all remain intact.
Verification on the combined branch:
1,036 unit tests passed; Ruff, mypy, and both import-linter contracts passed.
10 accounting scenarios and 5 attachment scenarios passed on Odoo 16–19 XML-RPC and Odoo 19 JSON-2.
General smoke passed on all four versions, including restricted-user/record-rule checks, addon install/update, Inspector, and Odoo 19 Streamable HTTP.
Integration options:
Since #78 now contains this PR's commits, you can either merge the combined #78 directly, or merge #71 first (preserving its commits via merge commit) and then #78. Note that squashing or rebasing #71 separately will break the shared commit ancestry and require rebasing #78 onto main afterward.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow draft manual journal entries to be created through
preview_write -> validate_write -> execute_approved_writewith validated new journal items, despite Odoo's UI-readonly metadata. Support single and atomic batch creates without merging distinct items on the same account.Reproduction and cause
On Odoo 16, preview and then validate this shape using valid journal/account IDs:
{ "model": "account.move", "operation": "create", "values": { "move_type": "entry", "journal_id": 7, "line_ids": [ [0, 0, {"name": "Item A", "account_id": 11, "debit": 10}], [0, 0, {"name": "Item B", "account_id": 11, "debit": 20}], [0, 0, {"name": "Counterpart", "account_id": 12, "credit": 30}] ] } }The existing validator rejects
line_idsandmove_typeas readonly, even though Odoo's ORM supports this atomic draft creation. The flag describes UI behavior rather than an absolute ORM create prohibition. In the tested Odoo 17–19 images,line_idsis writable butmove_typeremains readonly, so explicitmove_type="entry"also needs the narrow exception.Changes and scope
line_idsandmove_typeonaccount.movecreates whose effective type/state areentry/draft. Explicit values take precedence over context defaults.account.move.lineand fetch live child metadata from the same resolved instance.[0, 0, values]commands; reject unknown/readonly line fields, explicitmove_id, and nested one2many/many2many mutations.context.default_line_idsand disablingcheck_move_validityfor this creation contract.valuesandvalues_list.README.md,docs/, and the UnreleasedCHANGELOG.mdsection.Preserved gates and Odoo accounting checks
The existing write approval workflow is preserved: live metadata, validation in the same server session, a matching payload and token, approval expiry, explicit confirmation, and enabled writes. Client-supplied metadata cannot authorize execution. Direct
create,write, andunlinkremain blocked inexecute_method; field access controls and side-effect method policies are unchanged.Validation checks metadata and command structure, not a simulated accounting transaction. Odoo remains responsible for ACLs, record rules, company/journal/account compatibility, currencies, rounding, and balance. A failed single create or batch create rolls back its moves and items atomically.
action_postremains a separate transaction under the existing side-effect method policy.Verified compatibility
Official disposable Odoo Community Docker images; Python 3.12.12; package version unchanged at 1.3.2.
All 10 accounting scenarios verify the approval workflow, live metadata, unchanged payloads and tokens, distinct same-account items, posting, rollback on imbalance, and independent reconciliation. Batch tests also verify that an unbalanced second entry rolls back the whole batch and that reconciling one entry leaves the other untouched. Invalid fields, commands, and context values are rejected; missing validation, missing confirmation, tampered approvals, and direct creation are blocked.
The general smoke suite also verifies direct transport access, read/diagnostic tools, disabled standard writes, restricted-user access, complex record rules, packaged addon install/update, and locale plumbing.
Verification commands and results
runpywarning in the CLI entrypoint test.Limits
account.move.line.reconcilecommits successfully but its recordset-valued response fails serialization. Both accounting scenarios confirm the committed outcome by readback without retrying the operation. This PR does not fix that separate serialization issue.