[FIX] sms - mass_mailing(_sms) : small fixes

- In the mail/sms marketing, when we send a mass mailing (sms or not)
with the mailing list selected, all the mailing list is take in account,
domain is not correctly modify. Fix the onchange function.

TASK_ID : 2075733
This commit is contained in:
ryv-odoo
2019-09-30 09:37:11 +00:00
parent e572187af3
commit 2d5260e11b
+6 -8
View File
@@ -197,23 +197,21 @@ class MassMailing(models.Model):
else:
mass_mailing.next_departure = cron_time
@api.onchange('mailing_model_real', 'contact_list_ids')
@api.onchange('mailing_model_name', 'contact_list_ids')
def _onchange_model_and_list(self):
mailing_domain = literal_eval(self.mailing_domain) if self.mailing_domain else []
if self.mailing_model_real:
if self.mailing_model_name:
if mailing_domain:
try:
self.env[self.mailing_model_real].search(mailing_domain, limit=1)
self.env[self.mailing_model_name].search(mailing_domain, limit=1)
except:
mailing_domain = []
if not mailing_domain:
if self.mailing_model_real == 'mailing.list' and self.contact_list_ids:
if self.mailing_model_name == 'mailing.list' and self.contact_list_ids:
mailing_domain = [('list_ids', 'in', self.contact_list_ids.ids)]
elif self.mailing_model_real == 'res.partner' and 'customer_rank' in self.env['res.partner']._fields:
mailing_domain = [('customer_rank', '>', 0)]
elif 'is_blacklisted' in self.env[self.mailing_model_real]._fields and not self.mailing_domain:
elif 'is_blacklisted' in self.env[self.mailing_model_name]._fields and not self.mailing_domain:
mailing_domain = [('is_blacklisted', '=', False)]
elif 'opt_out' in self.env[self.mailing_model_real]._fields and not self.mailing_domain:
elif 'opt_out' in self.env[self.mailing_model_name]._fields and not self.mailing_domain:
mailing_domain = [('opt_out', '=', False)]
else:
mailing_domain = []