Skip to content

[19.0][FIX] partner_event: do not count the registrations of an unsaved partner - #557

Open
moylop260 wants to merge 1 commit into
OCA:19.0from
vauxoo-dev:19.0-fix-partner_event-new-record-count
Open

moylop260 wants to merge 1 commit into
OCA:19.0from
vauxoo-dev:19.0-fix-partner_event-new-record-count

Conversation

@moylop260

@moylop260 moylop260 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

registration_count of res.partner searches the registrations with partner.id. On a partner that is being created in a form (the onchange of a new contact) that id is a NewId, and domains do not support it:

Domains don't support NewId, use .ids instead, for ('attendee_partner_id', 'child_of', <NewId 0x7f...>)

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 with assertNoLogs("odoo.domains", level="WARNING"):

  • an unsaved partner has a count of 0;
  • a record built as the form builds it (new(..., origin=partner)) counts the registrations of the saved partner.

Run on Odoo 19.0 with only event and partner_event installed: without the fix the two tests fail (the warning above, and 0 != 1); with the fix the 14 tests of the module pass. pre-commit passes on the changed files.

…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
moylop260 force-pushed the 19.0-fix-partner_event-new-record-count branch from cf280be to f635ba5 Compare October 15, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants