Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
c057848e by Cédric Krier at 2023-01-01T13:25:17+01:00
Use Selection field for type of ir.action and add domain

Closes #1564
- - - - -


2 changed files:

- trytond/trytond/ir/action.py
- trytond/trytond/ir/view/action_form.xml


Changes:

=====================================
trytond/trytond/ir/action.py
=====================================
@@ -53,7 +53,12 @@
     "Action"
     __name__ = 'ir.action'
     name = fields.Char('Name', required=True, translate=True)
-    type = fields.Char('Type', required=True, readonly=True)
+    type = fields.Selection([
+            ('ir.action.report', "Report"),
+            ('ir.action.act_window', "Window"),
+            ('ir.action.wizard', "Wizard"),
+            ('ir.action.url', "URL"),
+            ], "Type", required=True, readonly=True)
     records = fields.Selection([
             ('selected', "Selected"),
             ('listed', "Listed"),
@@ -302,7 +307,10 @@
     _order_name = 'action'
     _action_name = 'name'
 
+    action = fields.Many2One(
+        'ir.action', "Action", required=True, ondelete='CASCADE')
+
     @classmethod
     def __setup__(cls):
         pool = Pool()
         super(ActionMixin, cls).__setup__()
@@ -305,7 +313,10 @@
     @classmethod
     def __setup__(cls):
         pool = Pool()
         super(ActionMixin, cls).__setup__()
+        cls.action.domain = [
+            ('type', '=', cls.__name__),
+            ]
         Action = pool.get('ir.action')
         for name in dir(Action):
             field = getattr(Action, name)
@@ -472,8 +483,6 @@
                 },
             depends=['template_extension']),
         'get_report_content_html', setter='set_report_content_html')
-    action = fields.Many2One('ir.action', 'Action', required=True,
-            ondelete='CASCADE')
     direct_print = fields.Boolean('Direct Print')
     single = fields.Boolean("Single",
         help="Check if the template works only for one record.")
@@ -746,8 +755,6 @@
         'act_window', 'Domains')
     domains = fields.Function(fields.Binary('Domains'), 'get_domains')
     limit = fields.Integer('Limit', help='Default limit for the list view.')
-    action = fields.Many2One('ir.action', 'Action', required=True,
-            ondelete='CASCADE')
     search_value = fields.Char('Search Criteria',
             help='Default search criteria for the list view.')
     pyson_domain = fields.Function(fields.Char('PySON Domain'), 'get_pyson')
@@ -1076,8 +1083,6 @@
     __name__ = 'ir.action.wizard'
     _action_name = 'wiz_name'
     wiz_name = fields.Char('Wizard name', required=True)
-    action = fields.Many2One('ir.action', 'Action', required=True,
-            ondelete='CASCADE')
     model = fields.Char('Model')
     window = fields.Boolean('Window', help='Run wizard in a new window.')
 
@@ -1101,8 +1106,6 @@
     "Action URL"
     __name__ = 'ir.action.url'
     url = fields.Char('Action Url', required=True)
-    action = fields.Many2One('ir.action', 'Action', required=True,
-            ondelete='CASCADE')
 
     @staticmethod
     def default_type():


=====================================
trytond/trytond/ir/view/action_form.xml
=====================================
@@ -8,6 +8,8 @@
     <field name="active" xexpand="0" width="100"/>
     <notebook colspan="4">
         <page string="General" id="general">
+            <label name="type"/>
+            <field name="type"/>
             <label name="records"/>
             <field name="records"/>
             <label name="usage"/>



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/c057848e1569fc8ae2ca64cc6553a124b0c5c5a2

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/c057848e1569fc8ae2ca64cc6553a124b0c5c5a2
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to