Repository navigation
Conversation
…tner
`registration_count` searched the registrations with `partner.id` in the
domain. On a partner that is being created in a form (onchange) the id
is a NewId, which domains do not support:
Domains don't support NewId, use .ids instead, for
('attendee_partner_id', 'child_of', <NewId 0x7f...>)
The ORM logs the warning and replaces the condition by an empty list, so
the result was right by accident, but the warning showed up every time a
contact was opened or edited.
Search with `partner.ids` instead: it has the id of the saved partner,
and none for a partner that does not exist yet. A saved partner being
edited now also counts its registrations, where the search returned 0.
moylop260
force-pushed
the
19.0-fix-partner_event-new-record-count
branch
from
October 15, 2026 19:05
cf280be to
f635ba5
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
registration_countofres.partnersearches the registrations withpartner.id. On a partner that is being created in a form (theonchangeof a new contact) that id is aNewId, and domains do not support it:The ORM logs the warning and turns the condition into an empty list, so the number was right by accident, but the warning is logged every time a contact is opened or created. On a saved partner that is being edited the search also returned 0.
The search now uses
partner.ids, as the warning suggests: it has the id of the saved partner, and none for a partner that does not exist yet.Tests
Two tests in
test_event_registration.py, both withassertNoLogs("odoo.domains", level="WARNING"):new(..., origin=partner)) counts the registrations of the saved partner.Run on Odoo 19.0 with only
eventandpartner_eventinstalled: without the fix the two tests fail (the warning above, and0 != 1); with the fix the 14 tests of the module pass.pre-commitpasses on the changed files.