Skip to content

Refactoring post init hook#15

Open
rfindling-gpc wants to merge 1 commit into
OCA:18.0from
rfindling-gpc:18.0
Open

Refactoring post init hook#15
rfindling-gpc wants to merge 1 commit into
OCA:18.0from
rfindling-gpc:18.0

Conversation

@rfindling-gpc
Copy link
Copy Markdown

This pull request refactors the post_init_hook function in mass_mailing_partner/hooks.py to replace Python-based contact-partner matching with SQL queries for improved performance. The changes aim to efficiently match mailing contacts to partners by email and synchronize their category tags using direct database operations instead of ORM iterations.

Changes:

Replaced Python loop for email-based contact-partner matching with a single SQL UPDATE statement
Added SQL queries to delete and re-insert contact-category relationships based on matched partner categories

Context:
We tried to initiate the app with previous mass mailing history, but mass_mailing_partner attempts to link historical mass mailing statistics (opens, clicks, bounces) to partners during installation. Without this step, only new contacts/statistics would be linked after installation, but this module tries to include historical data so reporting is complete from day one. The problem is that the linking function is inefficient: it processes records one by one. Since there are many records, the installation hits Odoo.sh time limits and fails.

Refactor contact matching to use SQL queries for efficiency. Added logging for updated mailing contacts.
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.

1 participant