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

[10.0][FIX][mass_mailing_list_dynamic] Fixed sync domain problem with escape characters. Added context… #384

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions mass_mailing_list_dynamic/models/mail_mass_mailing_list.py
Expand Up @@ -5,7 +5,6 @@
from odoo import api, fields, models
from odoo.tools import safe_eval


class MassMailingList(models.Model):
_inherit = "mail.mass_mailing.list"

Expand Down Expand Up @@ -43,7 +42,7 @@ def action_sync(self):
# Skip non-dynamic lists
dynamic = self.filtered("dynamic")
for one in dynamic:
sync_domain = safe_eval(one.sync_domain) + [("email", "!=", False)]
sync_domain = safe_eval(one.sync_domain.replace('u\'', '\'')) + [("email", "!=", False)]
Copy link
Member

Choose a reason for hiding this comment

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

Nothing forbids you to use unicode strings to search AFAIK, so this change doesn't seem to be actually fixing something.

OTOH, it's introducing a new real bug, where a domain like [('name', '=', 'Maru')] would be converted to [('name', '=', 'Mar')] and produce unexpected results.

I bet you're trying to fix a bug in the wrong place.

desired_partners = Partner.search(sync_domain)
# Remove undesired contacts when synchronization is full
if one.sync_method == "full":
Expand All @@ -55,7 +54,7 @@ def action_sync(self):
current_partners = current_contacts.mapped("partner_id")
# Add new contacts
for partner in desired_partners - current_partners:
Contact.create({
Contact.with_context(auto_created=True).create({
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide here a comment pointing to why it's done this way. I have read your main comment and I still don't understand it...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in an other module i extend the create function of mail.mass_mailing.contact to automatically send a double opt in mail to the new created contact. To be able to not send it, in the case the contact got created in some other way - i've added this context var.

Copy link
Member

Choose a reason for hiding this comment

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

Which module?

"list_id": one.id,
"partner_id": partner.id,
})
Expand Down