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

[14.0][MIG] partner_event: Migration to 14.0 #207

Merged
merged 25 commits into from
Nov 8, 2021

Conversation

chandni299
Copy link

Migration of partner_event from 13.0 to 14.0

antespi and others added 25 commits February 17, 2021 11:21
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/
Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some little changes according to code review.

Comment on lines +148 to +162

#~ msgid "Event attended registrations number"
#~ msgstr "Nº de registrados que han asistido al evento"

#~ msgid "Event registrations number"
#~ msgstr "Nº Registros a eventos"

#~ msgid "Events"
#~ msgstr "Eventos"

#~ msgid "Partner"
#~ msgstr "Empresa"

#~ msgid "or"
#~ msgstr "o"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#~ msgid "Event attended registrations number"
#~ msgstr "Nº de registrados que han asistido al evento"
#~ msgid "Event registrations number"
#~ msgstr "Nº Registros a eventos"
#~ msgid "Events"
#~ msgstr "Eventos"
#~ msgid "Partner"
#~ msgstr "Empresa"
#~ msgid "or"
#~ msgstr "o"

self._prepare_partner(values)
)
values["attendee_partner_id"] = attendee_partner.id
return super(EventRegistration, self).create(vals_list)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return super(EventRegistration, self).create(vals_list)
return super().create(vals_list)

)

def write(self, data):
res = super(ResPartner, self).write(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
res = super(ResPartner, self).write(data)
res = super().write(data)

attendee_partner = self.env.context.get("get_attendee_partner_address", False)
if attendee_partner:
return super(ResPartner, attendee_partner).address_get(adr_pref)
return super(ResPartner, self).address_get(adr_pref)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return super(ResPartner, self).address_get(adr_pref)
return super().address_get(adr_pref)

class TestEventRegistration(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestEventRegistration, cls).setUpClass()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
super(TestEventRegistration, cls).setUpClass()
super().setUpClass()

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although some small changes could be made they do not block and I think it could be merged.

@pedrobaeza pedrobaeza added this to the 14.0 milestone Nov 8, 2021
@pedrobaeza pedrobaeza changed the title 14.0 mig partner_event [14.0][MIG] partner_event: Migration to 14.0 Nov 8, 2021
@pedrobaeza
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 14.0-ocabot-merge-pr-207-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d6c753d into OCA:14.0 Nov 8, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 095d604. Thanks a lot for contributing to OCA. ❤️

@pedrobaeza
Copy link
Member

/ocabot migration partner_event

@OCA-git-bot OCA-git-bot mentioned this pull request Feb 7, 2022
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.