diff --git a/addons/mass_mailing/wizard/create_list.py b/addons/mass_mailing/wizard/create_list.py index 809aff62820..43ac1453f13 100644 --- a/addons/mass_mailing/wizard/create_list.py +++ b/addons/mass_mailing/wizard/create_list.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from openerp.osv import osv +from openerp.osv import osv, fields from openerp.tools.translate import _ @@ -9,11 +9,28 @@ class MailingListWizard(osv.TransientModel): allows to simplify and direct the user in the creation of its template without having to tune or hack the email.template model. """ _name = 'mail.mass_mailing.list.create' - _inherit = 'mail.mass_mailing.list' + + def _get_model_list(self, cr, uid, context=None): + return self.pool['mail.mass_mailing']._get_mailing_model(cr, uid, context=context) + + # indirections for inheritance + _model_list = lambda self, *args, **kwargs: self._get_model_list(*args, **kwargs) + + _columns = { + 'name': fields.char('Name', required=True), + 'model': fields.selection( + _model_list, type='char', required=True, + string='Applies To' + ), + } def action_new_list(self, cr, uid, ids, context=None): wizard = self.browse(cr, uid, ids[0], context=context) action_id = self.pool['mail.mass_mailing']._get_model_to_list_action_id(cr, uid, wizard.model, context=context) + if wizard.model == 'mail.mass_mailing.contact': + domain = [('list_id', '=', False)] + else: + domain = [] ctx = dict(context, search_default_not_opt_out=True, view_manager_highlight=[action_id], default_name=wizard.name, default_model=wizard.model) return { 'name': _('Choose Recipients'), @@ -22,4 +39,5 @@ class MailingListWizard(osv.TransientModel): 'view_mode': 'tree,form', 'res_model': wizard.model, 'context': ctx, + 'domain': domain, }