_primary_email was an array to be able to use it directly in the depends. Typically a 'depends' with a computed value (lambda) needs an array. Otherwise, it will only take the first character of the field name string. By setting _primary_email as a string, the lambda should always get an array. But it simplifies a lot the usage of the _primary_email. also, having an array was confusing as we could think that more than one field can be considered as the primary email. This is not the goal hare. So having the _primary_email as a single string is more 'self describing'. Only one field should be the _primary_email.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class MassMailTest(models.Model):
|
|
""" A very simple model only inheriting from mail.thread to test pure mass
|
|
mailing features and base performances. """
|
|
_description = 'Simple Mass Mailing Model'
|
|
_name = 'mass.mail.test'
|
|
_inherit = ['mail.thread', 'mail.address.mixin']
|
|
_primary_email = 'email_from'
|
|
|
|
name = fields.Char()
|
|
email_from = fields.Char()
|
|
|
|
|
|
class MassMailTestBlacklist(models.Model):
|
|
""" Model using blacklist mechanism for mass mailing. """
|
|
_description = 'Mass Mailing Model w Blacklist'
|
|
_name = 'mass.mail.test.bl'
|
|
_inherit = ['mail.thread', 'mail.blacklist.mixin']
|
|
|
|
_primary_email = 'email_from' # blacklist field to check
|
|
|
|
name = fields.Char()
|
|
email_from = fields.Char()
|
|
user_id = fields.Many2one(
|
|
'res.users', 'Responsible',
|
|
track_visibility='onchange')
|
|
umbrella_id = fields.Many2one(
|
|
'mail.test', 'Meta Umbrella Record',
|
|
track_visibility='onchange')
|