[FIX] mass_mailing,crm_mass_mailing: exclude opt-out

By default, when changing the recipients type of a
mass-mailing to partners or leads,
the selected records included the opt-out records.

To be consistent, as:
 - `opt-out` records are excluded by default for mass mailing contacts
 - the filter excluding the opt-out records
   `Available for mass-mailing` is loaded by default
   when changing the selection in the selection list dialog

The domain for partners and leads should exclude
opt-out records by default.

opw-658391
This commit is contained in:
Denis Ledoux 2015-12-08 14:59:20 +01:00
parent 83a4a582fa
commit 071144b0ac
2 changed files with 10 additions and 0 deletions

View File

@ -4,3 +4,11 @@ from openerp.osv import osv
class MassMailing(osv.Model):
_name = 'mail.mass_mailing'
_inherit = ['mail.mass_mailing', 'crm.tracking.mixin']
def on_change_model_and_list(self, cr, uid, ids, mailing_model, list_ids, context=None):
res = super(MassMailing, self).on_change_model_and_list(cr, uid, ids, mailing_model, list_ids, context=context)
if mailing_model == 'crm.lead':
res = res or {}
values = {'mailing_domain': "[('opt_out', '=', False)]"}
res = dict(res, value=dict(res.get('value', {}), **values))
return res

View File

@ -517,6 +517,8 @@ class MassMailing(osv.Model):
value['mailing_domain'] = "[('list_id', 'in', %s), ('opt_out', '=', False)]" % list(mailing_list_ids)
else:
value['mailing_domain'] = "[('list_id', '=', False)]"
elif mailing_model in ['res.partner']:
value['mailing_domain'] = "[('opt_out', '=', False)]"
else:
value['mailing_domain'] = []
return {'value': value}