From 4498ec3f7d579f301ca0c9ff2ac03c944e4dd4ae Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 6 Jan 2022 12:18:50 +0000 Subject: [PATCH] [FIX] mass_mailing: ignore default_list_ids when list_ids is given Bug === Since 576556d84668a950020486f788dcf3bf30cc8515 we merged the list coming from the context key default_list_ids and the list given by the user in subscription_list_ids. It worked well because the 2 fields "list_ids" and "subscription_list_ids" were not in the same view at the same time. But if we want to create from the backend by giving a value in "list_ids", the context key "default_list_ids" must be ignored (like standard Odoo fields). Task-2703521 Part-of: odoo/odoo#82333 --- addons/mass_mailing/models/mailing_contact.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/mass_mailing/models/mailing_contact.py b/addons/mass_mailing/models/mailing_contact.py index 75ea8d0f15c..3c3d6460c29 100644 --- a/addons/mass_mailing/models/mailing_contact.py +++ b/addons/mass_mailing/models/mailing_contact.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import _, api, fields, models +from odoo.exceptions import UserError from odoo.osv import expression @@ -134,8 +135,14 @@ class MassMailingContact(models.Model): default_list_ids = self._context.get('default_list_ids') default_list_ids = default_list_ids if isinstance(default_list_ids, (list, tuple)) else [] + for vals in vals_list: + if vals.get('list_ids') and vals.get('subscription_list_ids'): + raise UserError(_('You should give either list_ids, either subscription_list_ids to create new contacts.')) + if default_list_ids: for vals in vals_list: + if vals.get('list_ids'): + continue current_list_ids = [] subscription_ids = vals.get('subscription_list_ids') or [] for subscription in subscription_ids: