Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] partner_event: Migration to 18.0 #435

Open
wants to merge 47 commits into
base: 18.0
Choose a base branch
from

Conversation

HeliconiaSolutions
Copy link

No description provided.

antespi and others added 30 commits February 3, 2025 15:12
These fields were stored. That usually is good, but if you add partners to an event from the wizard, it means each `res.partner` record gets its `registration_count` field updated.

When you update any record, fields `write_uid` and `write_date` are updated too.

Now imagine you want to add 4000 partners to an event. That would take time. If in the mean time any other user updates the `res.partner` record (along with their `write_UID` and `WRITE_DATE` fields), you would get this error:

```
openerp.sql_db: bad query: UPDATE "res_partner" SET "registration_count"=3,"write_uid"=5,"write_date"=(now() at time zone 'UTC') WHERE id IN (25578)
Traceback (most recent call last):
  File "/opt/odoo/common/openerp/v8/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
TransactionRollbackError: could not serialize access due to concurrent update
CONTEXT:  SQL statement "SELECT 1 FROM ONLY "public"."res_users" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x"
```

By removing the `store=True` parameter, you simply avoid those concurrent updates and do not block other users.

But this changes the database structure, so remember to update your database!
If adding 1000 partners, we save now 999 queries.

(cherry picked from commit 89853ef)
Currently translated at 100.0% (24 of 24 strings)

Translation: event-12.0/event-12.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-12-0/event-12-0-partner_event/es/
…oint

For speeding up the process. Specially the removal of the savepoints
makes that Postgres don't go slow as hell. Check
https://www.cybertec-postgresql.com/en/subtransactions-and-performance-in-postgresql/
for some rationale. The problem happens even releasing the previous
savepoints.

As this module is very old, the reason for doing it this way and skip
registrations with error is not fully known, but the view mentions about
registration duplication, so let's avoid it and handle later other
possible exceptions.

TT26694
When we confirm a sale order, the registrations are precreated without
the email info, so we were missing the chance to get the info for the
partner attendant.

Now we compute it on the write as well.

TT45149
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/
Currently translated at 100.0% (23 of 23 strings)

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/es/
mymage and others added 17 commits February 3, 2025 15:12
Currently translated at 100.0% (23 of 23 strings)

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/it/
Steps to reproduce:

- Have several partners with the same email.
- Generate an event registration for each of the partners.
- Launch the contact merge wizard.
- Select the destination contact the one with the name that is
  alphabetically later.
- Launch the merge.

Current behavior:

Model: Event Registration (event.registration), Constraint: event_registration_attendee_partner_id_fkey

ERROR: update or delete on table "res_partner" violates foreign key constraint "event_registration_attendee_partner_id_fkey" on table "event_registration"
DETAIL:  Key (id)=(NNN) is still referenced from table "event_registration"

Expected behavior:

Succesful merge.

The problem arises when ORM launches a flush before unlinking partners.
Such recomputation launches a write on existing event registration
records, which calls the update of the attendee_partner_id.

To prevent it, we just skip such process if performing the merge.

TT46798
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/
Currently translated at 100.0% (24 of 24 strings)

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/es/
Currently translated at 100.0% (24 of 24 strings)

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/it/
Currently translated at 100.0% (24 of 24 strings)

Translation: event-16.0/event-16.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-16-0/event-16-0-partner_event/sv/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: event-17.0/event-17.0-partner_event
Translate-URL: https://translation.odoo-community.org/projects/event-17-0/event-17-0-partner_event/
The search by email is limited to 1 record and without the order clause
is using the default order that is defined in
https://github.com/odoo/odoo/blob/7f3863bdeb21ecfb7ac1859641bddf3de5dd8643/odoo/addons/base/models/res_partner.py#L178
and it could be customized since the default order could cause a slow
query this adds an "order" clause in the search to prevent the use of
the default order and use the ID instead.

The partner got from the search has to match with the email searched,
so any result is useful for this case.
@pedrobaeza
Copy link
Member

/ocabot migration partner_event

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Feb 3, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Feb 3, 2025
10 tasks
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.