[FIX] mass_mailing: do not reset mailing_domain when changing model

Indeed due to onchange being trigerred at creation it breaks trying to
set default_mailing_domain when creating a new mailing through the web
client.

As setting domain and then changing model should not be the primary use
case of mass mailing, people will have to update their domain manually
instead of seeing it reset to a void domain.
This commit is contained in:
Thibault Delavallée
2017-04-18 14:37:38 +02:00
parent 05a3305274
commit dce1a52b8b
+1 -3
View File
@@ -459,10 +459,8 @@ class MassMailing(models.Model):
self.mailing_domain = "[('list_ids', 'in', [%s]), ('opt_out', '=', False)]" % (','.join(map(str,self.contact_list_ids.ids)),)
else:
self.mailing_domain = "[(0, '=', 1)]"
elif 'opt_out' in self.env[self.mailing_model]._fields:
elif 'opt_out' in self.env[self.mailing_model]._fields and not self.mailing_domain:
self.mailing_domain = "[('opt_out', '=', False)]"
else:
self.mailing_domain = []
self.body_html = "on_change_model_and_list"
#------------------------------------------------------