diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index 89df42268c7..e79a5aab5a8 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -24,6 +24,28 @@ class MassMailingCategory(osv.Model): } +class MassMailingList(osv.Model): + """Model of a contact list. """ + _name = 'mail.mass_mailing.list' + _order = 'name' + _description = 'Mailing List' + + def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None): + result = dict.fromkeys(ids, 0) + Contacts = self.pool.get('mail.mass_mailing.contact') + for group in Contacts.read_group(cr, uid, [('list_id', 'in', ids), ('opt_out', '!=', True)], ['list_id'], ['list_id'], context=context): + result[group['list_id'][0]] = group['list_id_count'] + return result + + _columns = { + 'name': fields.char('Mailing List', required=True), + 'contact_nbr': fields.function( + _get_contact_nbr, type='integer', + string='Number of Contacts', + ), + } + + class MassMailingContact(osv.Model): """Model of a contact. This model is different from the partner model because it holds only some basic information: name, email. The purpose is to @@ -79,28 +101,6 @@ class MassMailingContact(osv.Model): return res -class MassMailingList(osv.Model): - """Model of a contact list. """ - _name = 'mail.mass_mailing.list' - _order = 'name' - _description = 'Mailing List' - - def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None): - result = dict.fromkeys(ids, 0) - Contacts = self.pool.get('mail.mass_mailing.contact') - for group in Contacts.read_group(cr, uid, [('list_id', 'in', ids), ('opt_out', '!=', True)], ['list_id'], ['list_id'], context=context): - result[group['list_id'][0]] = group['list_id_count'] - return result - - _columns = { - 'name': fields.char('Mailing List', required=True), - 'contact_nbr': fields.function( - _get_contact_nbr, type='integer', - string='Number of Contacts', - ), - } - - class MassMailingStage(osv.Model): """Stage for mass mailing campaigns. """ _name = 'mail.mass_mailing.stage'