[IMP] base,base_automation,mail,sms: server action UX

- Slight reword of the 'type/state' field labels for server actions
- Re-ordering of 'type/state' values
- Form view changes
- Allow hiding model in display_name of ir.model.fields base on context
  key (avoid technical details when they are not needed)

Task-3450200

Part-of: odoo/odoo#138804
This commit is contained in:
Damien Bouvy
2023-10-26 13:41:07 +00:00
parent 278dece52f
commit 203af43784
5 changed files with 31 additions and 23 deletions
+6 -4
View File
@@ -14,10 +14,12 @@ class ServerActions(models.Model):
_inherit = ['ir.actions.server']
state = fields.Selection(
selection_add=[('mail_post', 'Send Email'),
('followers', 'Add Followers'),
('remove_followers', 'Remove Followers'),
('next_activity', 'Create Next Activity'),
selection_add=[
('next_activity', 'Create Activity'),
('mail_post', 'Send Email'),
('followers', 'Add Followers'),
('remove_followers', 'Remove Followers'),
('object_create',),
],
ondelete={'mail_post': 'cascade',
'followers': 'cascade',
+1 -1
View File
@@ -11,7 +11,7 @@ class ServerActions(models.Model):
_inherit = ['ir.actions.server']
state = fields.Selection(selection_add=[
('sms', 'Send SMS Text Message'),
('sms', 'Send SMS'), ('followers',),
], ondelete={'sms': 'cascade'})
# SMS
sms_template_id = fields.Many2one(
+11 -11
View File
@@ -465,20 +465,20 @@ class IrActionsServer(models.Model):
('ir_cron', 'Scheduled Action')], string='Usage',
default='ir_actions_server', required=True)
state = fields.Selection([
('code', 'Execute Python Code'),
('object_create', 'Create a new Record'),
('object_write', 'Update the Record'),
('multi', 'Execute several actions')], string='Type',
default='code', required=True, copy=True,
('object_write', 'Update Record'),
('object_create', 'Create Record'),
('code', 'Execute Code'),
('multi', 'Execute existing actions')], string='Type',
default='object_write', required=True, copy=True,
help="Type of server action. The following values are available:\n"
"- 'Execute Python Code': a block of python code that will be executed\n"
"- 'Create a new Record': create a new record with new values\n"
"- 'Update a Record': update the values of a record\n"
"- 'Execute several actions': define an action that triggers several other server actions\n"
"- 'Create Activity': create an activity (Discuss)\n"
"- 'Send Email': post a message, a note or send an email (Discuss)\n"
"- 'Add Followers': add followers to a record (Discuss)\n"
"- 'Create Next Activity': create an activity (Discuss)\n"
"- 'Send SMS Text Message': send SMS, log them on documents (SMS)")
"- 'Send SMS': send SMS, log them on documents (SMS)"
"- 'Add/Remove Followers': add or remove followers to a record (Discuss)\n"
"- 'Create Record': create a new record with new values\n"
"- 'Execute Code': a block of Python code that will be executed\n"
"- 'Execute existing actions': define an action that triggers several other server actions\n")
# Generic
sequence = fields.Integer(default=5,
help="When dealing with multiple actions, the execution order is "
+3
View File
@@ -1072,6 +1072,9 @@ class IrModelFields(models.Model):
def _compute_display_name(self):
IrModel = self.env["ir.model"]
for field in self:
if self.env.context.get('hide_model'):
field.display_name = field.field_description
continue
model_string = IrModel._get(field.model).name
field.display_name = f'{field.field_description} ({model_string})'
+10 -7
View File
@@ -329,6 +329,10 @@
<h1 class="oe_title">
<field name="name" placeholder="e.g. Mass archive contacts"/>
</h1>
<div class="d-flex flex-column">
<label for="state"/>
<field name="state" widget="selection_badge"/>
</div>
<group name="action_wrapper">
<group name="action_content">
<field name="model_name" invisible="1"/>
@@ -338,9 +342,8 @@
<field name="model_id" options="{'no_create': True, 'no_open': True}" groups="!base.group_no_one" invisible="context.get('default_model_id')"
domain="[('id', 'in', available_model_ids)]"/>
<field name="groups_id" widget="many2many_tags" groups="base.group_no_one" />
<field name="state" string="Action Type"/>
<field name="update_field_id" invisible="state != 'object_write'"
options="{'no_create': True, 'no_open': True}"
options="{'no_create': True, 'no_open': True}" context="{'hide_model': True}"/>
domain="['|', ('model_id', '=', crud_model_id), ('model_id', '=', model_id)]"/>
<field name="evaluation_type" invisible="state != 'object_write'" widget="radio" options="{'horizontal': True}"/>
<field name="value_field_to_show" invisible="1"/>
@@ -384,11 +387,11 @@
<page string="Actions" name="actions"
invisible="state != 'multi'">
<p class="oe_grey">
If several child actions return an action, only the last one will be executed.
This may happen when having server actions executing code that returns an action, or server actions returning a client action.
</p>
<field name="child_ids" domain="[('model_id', '=', model_id)]"/>
<field name="child_ids" domain="[('model_id', '=', model_id)]"/>
<p class="oe_grey">
If several child actions return an action, only the last one will be executed.
This may happen when having server actions executing code that returns an action, or server actions returning a client action.
</p>
</page>
<page string="Help" name="help_info"