details:   https://code.tryton.org/tryton/commit/cdc632a60b8a
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Mon Sep 29 13:16:49 2025 +0200
description:
        Add test that fields in __access__ are required

        Closes #14261
diffstat:

 modules/account/account.py                    |  3 ++-
 modules/account_move_line_grouping/account.py |  3 ++-
 modules/account_statement/statement.py        |  3 ++-
 modules/currency/currency.py                  |  2 +-
 modules/party/party.py                        |  2 +-
 modules/product_image/product.py              |  2 +-
 modules/product_kit/product.py                |  2 +-
 trytond/trytond/ir/action.py                  |  4 ++--
 trytond/trytond/tests/test_tryton.py          |  3 +++
 9 files changed, 15 insertions(+), 9 deletions(-)

diffs (121 lines):

diff -r 769ec2410d30 -r cdc632a60b8a modules/account/account.py
--- a/modules/account/account.py        Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/account/account.py        Mon Sep 29 13:16:49 2025 +0200
@@ -2329,7 +2329,8 @@
 
     move = fields.Many2One('account.move', 'Move')
     date = fields.Date('Date')
-    account = fields.Many2One('account.general_ledger.account', 'Account')
+    account = fields.Many2One(
+        'account.general_ledger.account', 'Account', required=True)
     party = fields.Many2One('party.party', 'Party',
         states={
             'invisible': ~Eval('party_required', False),
diff -r 769ec2410d30 -r cdc632a60b8a 
modules/account_move_line_grouping/account.py
--- a/modules/account_move_line_grouping/account.py     Sat Oct 11 13:27:37 
2025 +0200
+++ b/modules/account_move_line_grouping/account.py     Mon Sep 29 13:16:49 
2025 +0200
@@ -40,7 +40,8 @@
 class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView):
     __name__ = 'account.move.line.group'
 
-    move = fields.Many2One('account.move', "Move", readonly=True)
+    move = fields.Many2One(
+        'account.move', "Move", readonly=True, required=True)
     account = fields.Many2One(
         'account.account', "Account", readonly=True,
         context={
diff -r 769ec2410d30 -r cdc632a60b8a modules/account_statement/statement.py
--- a/modules/account_statement/statement.py    Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/account_statement/statement.py    Mon Sep 29 13:16:49 2025 +0200
@@ -1086,7 +1086,8 @@
 class LineGroup(ModelSQL, ModelView):
     __name__ = 'account.statement.line.group'
     _rec_name = 'number'
-    statement = fields.Many2One('account.statement', 'Statement')
+    statement = fields.Many2One(
+        'account.statement', 'Statement', required=True)
     journal = fields.Function(fields.Many2One('account.statement.journal',
             'Journal'), 'get_journal', searcher='search_journal')
     number = fields.Char('Number')
diff -r 769ec2410d30 -r cdc632a60b8a modules/currency/currency.py
--- a/modules/currency/currency.py      Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/currency/currency.py      Mon Sep 29 13:16:49 2025 +0200
@@ -254,7 +254,7 @@
             ],
         help="The floating exchange rate used to convert the currency.")
     currency = fields.Many2One('currency.currency', 'Currency',
-            ondelete='CASCADE',
+        required=True, ondelete='CASCADE',
         help="The currency on which the rate applies.")
 
     @classmethod
diff -r 769ec2410d30 -r cdc632a60b8a modules/party/party.py
--- a/modules/party/party.py    Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/party/party.py    Mon Sep 29 13:16:49 2025 +0200
@@ -819,7 +819,7 @@
     @classmethod
     def __setup__(cls):
         super().__setup__()
-        cls.__access__.update(['party', 'address'])
+        cls.__access__.add('party')
 
     @classmethod
     def __register__(cls, module_name):
diff -r 769ec2410d30 -r cdc632a60b8a modules/product_image/product.py
--- a/modules/product_image/product.py  Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/product_image/product.py  Mon Sep 29 13:16:49 2025 +0200
@@ -237,7 +237,7 @@
     @classmethod
     def __setup__(cls):
         super().__setup__()
-        cls.__access__.update(['product', 'template'])
+        cls.__access__.add('template')
 
     def _store_cache(self, size, image):
         cache = super()._store_cache(size, image)
diff -r 769ec2410d30 -r cdc632a60b8a modules/product_kit/product.py
--- a/modules/product_kit/product.py    Sat Oct 11 13:27:37 2025 +0200
+++ b/modules/product_kit/product.py    Mon Sep 29 13:16:49 2025 +0200
@@ -245,7 +245,7 @@
     @classmethod
     def __setup__(cls):
         super().__setup__()
-        cls.__access__.update(['parent_template', 'parent_product'])
+        cls.__access__.add('parent_template')
 
     @fields.depends(
         'parent_product', '_parent_parent_product.template')
diff -r 769ec2410d30 -r cdc632a60b8a trytond/trytond/ir/action.py
--- a/trytond/trytond/ir/action.py      Sat Oct 11 13:27:37 2025 +0200
+++ b/trytond/trytond/ir/action.py      Mon Sep 29 13:16:49 2025 +0200
@@ -186,7 +186,7 @@
             ('graph_open', 'Open Graph'),
             ], string='Keyword', required=True)
     model = fields.Reference('Model', selection='models_get')
-    action = fields.Many2One('ir.action', 'Action',
+    action = fields.Many2One('ir.action', 'Action', required=True,
         ondelete='CASCADE')
     groups = fields.Function(
         fields.Many2Many('res.group', None, None, "Groups"),
@@ -973,7 +973,7 @@
             ('model', '=', Eval('model', None)),
             ])
     act_window = fields.Many2One('ir.action.act_window', 'Action',
-            ondelete='CASCADE')
+        required=True, ondelete='CASCADE')
     model = fields.Function(fields.Char("Model"), 'on_change_with_model')
 
     @classmethod
diff -r 769ec2410d30 -r cdc632a60b8a trytond/trytond/tests/test_tryton.py
--- a/trytond/trytond/tests/test_tryton.py      Sat Oct 11 13:27:37 2025 +0200
+++ b/trytond/trytond/tests/test_tryton.py      Mon Sep 29 13:16:49 2025 +0200
@@ -416,6 +416,9 @@
                         msg="Wrong __access__ '%s' for %s" % (
                             field_name, mname))
                     field = Model._fields[field_name]
+                    self.assertTrue(field.required,
+                        msg=("Field '%s' of '%s' must be required in order to "
+                            "be used in __access__") % (field_name, mname))
                     Target = field.get_target()
                     self.assertTrue(
                         Target,

Reply via email to