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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
@@ -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)] | ||
desired_partners = Partner.search(sync_domain) | ||
# Remove undesired contacts when synchronization is full | ||
if one.sync_method == "full": | ||
|
@@ -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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which module? |
||
"list_id": one.id, | ||
"partner_id": partner.id, | ||
}) | ||
|
There was a problem hiding this comment.
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.