Use Selection field for type of ir.action and add domain

Closes #1564
This commit is contained in:
Cédric Krier
2023-01-01 13:25:17 +01:00
parent 5d074f963a
commit 72699d6880
2 changed files with 14 additions and 9 deletions
+12 -9
View File
@@ -53,7 +53,12 @@ class Action(DeactivableMixin, ModelSQL, ModelView):
"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,10 +307,16 @@ class ActionMixin(ModelSQL):
_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__()
cls.action.domain = [
('type', '=', cls.__name__),
]
Action = pool.get('ir.action')
for name in dir(Action):
field = getattr(Action, name)
@@ -472,8 +483,6 @@ class ActionReport(ActionMixin, ModelSQL, ModelView):
},
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 @@ class ActionActWindow(ActionMixin, ModelSQL, ModelView):
'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 @@ class ActionWizard(ActionMixin, ModelSQL, ModelView):
__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 @@ class ActionURL(ActionMixin, ModelSQL, ModelView):
"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():
+2
View File
@@ -8,6 +8,8 @@ this repository contains the full copyright notices and license terms. -->
<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"/>