changeset 4fdea4baa929 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset&node=4fdea4baa929
description:
        Set full domain on email template setup

        issue10517
        review352191002
        (grafted from 424253ecacc46841a2342e6cf9a9aa6efb0dd055)
diffstat:

 trytond/ir/email_.py |  23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diffs (68 lines):

diff -r 74db752eb4e9 -r 4fdea4baa929 trytond/ir/email_.py
--- a/trytond/ir/email_.py      Thu Jul 01 21:38:06 2021 +0200
+++ b/trytond/ir/email_.py      Tue Jun 29 11:57:04 2021 +0200
@@ -252,13 +252,10 @@
     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",
@@ -270,13 +267,10 @@
         '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",
@@ -288,13 +282,10 @@
         '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",
@@ -326,13 +317,17 @@
                 '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(),

Reply via email to