From e0134a2bfa9253b372073b7bbb0b6e66f551f7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 31 Mar 2014 13:06:26 +0200 Subject: [PATCH] [IMP] mass_mailing: create wizard: do not inherit from mailing list anymore, just have the necessary fields to simplify bzr revid: tde@openerp.com-20140331110626-iewarhctoyoaucsg --- addons/mass_mailing/wizard/create_list.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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, }