diff --git a/trytond/ir/email_.py b/trytond/ir/email_.py index f39e232609..a7c523711f 100644 --- a/trytond/ir/email_.py +++ b/trytond/ir/email_.py @@ -256,13 +256,10 @@ class EmailTemplate(ModelSQL, ModelView): name = fields.Char("Name", required=True, translate=True) recipients = fields.Many2One( 'ir.model.field', "Recipients", - domain=[ - ('model', '=', Eval('model')), - ], states={ 'invisible': Bool(Eval('recipients_pyson')), }, - depends=['model', 'recipients_pyson'], + depends=['recipients_pyson'], help="The field that contains the recipient(s).") recipients_pyson = fields.Char( "Recipients", @@ -274,13 +271,10 @@ class EmailTemplate(ModelSQL, ModelView): 'with the record represented by "self".') recipients_secondary = fields.Many2One( 'ir.model.field', "Secondary Recipients", - domain=[ - ('model', '=', Eval('model')), - ], states={ 'invisible': Bool(Eval('recipients_secondary_pyson')), }, - depends=['model', 'recipients_secondary_pyson'], + depends=['recipients_secondary_pyson'], help="The field that contains the secondary recipient(s).") recipients_secondary_pyson = fields.Char( "Secondary Recipients", @@ -292,13 +286,10 @@ class EmailTemplate(ModelSQL, ModelView): 'of secondary recipients with the record represented by "self".') recipients_hidden = fields.Many2One( 'ir.model.field', "Hidden Recipients", - domain=[ - ('model', '=', Eval('model')), - ], states={ 'invisible': Bool(Eval('recipients_hidden_pyson')), }, - depends=['model', 'recipients_hidden_pyson'], + depends=['recipients_hidden_pyson'], help="The field that contains the secondary recipient(s).") recipients_hidden_pyson = fields.Char( "Hidden Recipients", @@ -330,13 +321,17 @@ class EmailTemplate(ModelSQL, ModelView): 'recipients_hidden', ]: field = getattr(cls, field) - field.domain.append(['OR', + field.domain = [ + ('model', '=', Eval('model')), + ['OR', ('relation', 'in', cls.email_models()), [ ('model.model', 'in', cls.email_models()), ('name', '=', 'id'), ], - ]) + ] + ] + field.depends.append('model') cls.__rpc__.update({ 'get': RPC(instantiate=0), 'get_default': RPC(),