diff options
| author | Priyanka Kakadiya <pka@odoo.com> | 2020-10-08 07:27:26 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-10-19 09:51:10 +0000 |
| commit | 5ccf5b51feaa348d775890e107fd30cd750699d8 (patch) | |
| tree | d1c1b91e279a72074784461697602968626f0de0 | |
| parent | 3d3aca543c051dfce1fcb87578d859caa0406f5e (diff) | |
[FIX] mass_mailing: do not add `opt_out` by default on mailing domains
In mass mailing (_sms) when you set `Mailing Contact` as target model the
`opt_out` field is added to the default domain. However as it is a computed
field depending on a single mailing list given in context it should not be
used that way. Moreover current implementation raises a warning as only some
custom views can use this field accordingly.
This commit removes `opt_out` field being set by default in mailing domain and
also removes the UserError raised by the search function, thus avoiding
unwanted warnings.
Opt-out field is automatically taken into account when sending mass mailing on
contacts (see ``_get_opt_out_list``) so removing it from domain is actually
even better for coherency. Opt-out is not an option in sending process.
Task Id-2300427
PR #57310
Related: odoo/enterprise#14065
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
| -rw-r--r-- | addons/mass_mailing/models/mailing.py | 2 | ||||
| -rw-r--r-- | addons/mass_mailing/models/mailing_contact.py | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/addons/mass_mailing/models/mailing.py b/addons/mass_mailing/models/mailing.py index 5136ae91624..abc63381bf7 100644 --- a/addons/mass_mailing/models/mailing.py +++ b/addons/mass_mailing/models/mailing.py @@ -771,8 +771,6 @@ class MassMailing(models.Model): if self.mailing_type == 'mail' and 'is_blacklisted' in self.env[self.mailing_model_name]._fields: mailing_domain = expression.AND([[('is_blacklisted', '=', False)], mailing_domain]) - if self.mailing_type == 'mail' and 'opt_out' in self.env[self.mailing_model_name]._fields: - mailing_domain = expression.AND([[('opt_out', '=', False)], mailing_domain]) return mailing_domain diff --git a/addons/mass_mailing/models/mailing_contact.py b/addons/mass_mailing/models/mailing_contact.py index 95627f4260e..6ebd1132820 100644 --- a/addons/mass_mailing/models/mailing_contact.py +++ b/addons/mass_mailing/models/mailing_contact.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools, _ -from odoo.exceptions import UserError +from odoo import api, fields, models +from odoo.osv import expression class MassMailingContactListRel(models.Model): @@ -77,7 +77,7 @@ class MassMailingContact(models.Model): contacts = self.env['mailing.contact.subscription'].search([('list_id', '=', active_list_id)]) return [('id', 'in', [record.contact_id.id for record in contacts if record.opt_out == value])] else: - raise UserError(_('Search opt out cannot be executed without a unique and valid active mailing list context.')) + return expression.FALSE_DOMAIN if value else expression.TRUE_DOMAIN @api.depends('subscription_list_ids') def _compute_opt_out(self): |
