[IMP] base_automation: better UX
This commit improves the general feel when creating or displaying base automations The improvement relies mainly on correctly labelling the fields task-id-3450200 closes odoo/odoo#135932 Related: odoo/enterprise#47609 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -12,7 +12,6 @@ const OPT_GROUPS = [
|
||||
{
|
||||
group: { sequence: 10, key: "values", name: _lt("Values Updated") },
|
||||
triggers: [
|
||||
"on_create_or_write",
|
||||
"on_stage_set",
|
||||
"on_user_set",
|
||||
"on_tag_set",
|
||||
@@ -28,7 +27,7 @@ const OPT_GROUPS = [
|
||||
},
|
||||
{
|
||||
group: { sequence: 40, key: "custom", name: _lt("Custom") },
|
||||
triggers: ["on_unlink", "on_change"],
|
||||
triggers: ["on_create_or_write", "on_unlink", "on_change"],
|
||||
},
|
||||
{
|
||||
group: { sequence: 50, key: "external", name: _lt("External") },
|
||||
@@ -64,6 +63,7 @@ function computeDerivedOptions(options, fields, currentSelection, { excludeGroup
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const option = { group, value, label };
|
||||
derivedOptions.push(option);
|
||||
}
|
||||
|
||||
@@ -131,9 +131,14 @@
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click row g-0 align-items-center">
|
||||
<div class="d-flex align-items-center">
|
||||
<field name="sequence" widget="handle" class="px-3" />
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<field name="sequence" widget="handle" class="px-1" />
|
||||
<field name="state" invisible="1" />
|
||||
<field name="evaluation_type" invisible="1" />
|
||||
<field name="value" invisible="1" />
|
||||
<field name="selection_value" invisible="1" />
|
||||
<field name="value_field_to_show" invisible="1"/>
|
||||
|
||||
<!-- Icon section -->
|
||||
<i
|
||||
data-name="server_action_icon"
|
||||
@@ -151,8 +156,19 @@
|
||||
'sms': 'fa-comments-o',
|
||||
}[record.state.raw_value]"
|
||||
/>
|
||||
<field name="name" class="ps-2 text-truncate w-0 flex-grow-1" />
|
||||
<button type="delete" name="delete" class="btn fa fa-trash fa-xl px-3" title="Delete Action" />
|
||||
<field name="name" class="text-truncate" />
|
||||
<t invisible="state != 'object_write'">
|
||||
<code invisible="evaluation_type != 'equation'" t-esc="record.value.raw_value"/>
|
||||
<span invisible="evaluation_type == 'equation'" >
|
||||
<field name="selection_value" invisible="value_field_to_show != 'selection_value'" class="d-inline"/>
|
||||
<span invisible="value_field_to_show == 'selection_value'">
|
||||
<span invisible="value == False or evaluation_type == False">"</span>
|
||||
<field name="value" class="d-inline"/>
|
||||
<span invisible="value == False or evaluation_type == False">"</span>
|
||||
</span>
|
||||
</span>
|
||||
</t>
|
||||
<button type="delete" name="delete" class="btn fa fa-trash fa-xl px-3 ms-auto" title="Delete Action" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -142,10 +142,10 @@ registry.category("web_tour.tours").add("test_base_automation_on_tag_added", {
|
||||
on_user_set: "User is set",
|
||||
on_tag_set: "Tag is added",
|
||||
on_priority_set: "Priority is set to",
|
||||
on_create_or_write: "On save",
|
||||
on_time: "Based on date field",
|
||||
on_time_created: "After creation",
|
||||
on_time_updated: "After last update",
|
||||
on_create_or_write: "On save",
|
||||
on_unlink: "On deletion",
|
||||
on_change: "On live update",
|
||||
on_webhook: "On webhook",
|
||||
@@ -299,7 +299,7 @@ registry.category("web_tour.tours").add("test_kanban_automation_view_time_trigge
|
||||
);
|
||||
assertEqual(
|
||||
document.querySelector(".o_kanban_record .o_tag").innerText,
|
||||
"Date (res.partner)"
|
||||
"Date (Contact)"
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -454,7 +454,7 @@ registry.category("web_tour.tours").add("test_form_view_model_id", {
|
||||
);
|
||||
assertEqual(
|
||||
triggerGroups.map((el) => el.innerText).join(" // "),
|
||||
"User is setOn save // Based on date fieldAfter creationAfter last update // On deletionOn live update // On webhook"
|
||||
"User is set // Based on date fieldAfter creationAfter last update // On saveOn deletionOn live update // On webhook"
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -488,7 +488,7 @@ registry.category("web_tour.tours").add("test_form_view_model_id", {
|
||||
);
|
||||
assertEqual(
|
||||
triggerGroups.map((el) => el.innerText).join(" // "),
|
||||
"Stage is set toUser is setTag is addedPriority is set toOn save // Based on date fieldAfter creationAfter last update // On deletionOn live update // On webhook"
|
||||
"Stage is set toUser is setTag is addedPriority is set to // Based on date fieldAfter creationAfter last update // On saveOn deletionOn live update // On webhook"
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -79,7 +79,6 @@ class BaseAutomationTestUi(HttpCase):
|
||||
self.assertEqual(base_auto.trg_field_ref_model_name, "test_base_automation.tag")
|
||||
self.assertEqual(base_auto.trg_field_ref, tag.id)
|
||||
|
||||
|
||||
def test_kanban_automation_view_stage_trigger(self):
|
||||
self._neutralize_preexisting_automations()
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@ class IrActionsServer(models.Model):
|
||||
groups_id = fields.Many2many('res.groups', 'ir_act_server_group_rel',
|
||||
'act_id', 'gid', string='Allowed Groups', help='Groups that can execute the server action. Leave empty to allow everybody.')
|
||||
|
||||
update_field_id = fields.Many2one('ir.model.fields', string='Field to update', default=_default_update_field_id, ondelete='cascade')
|
||||
update_field_id = fields.Many2one('ir.model.fields', string='Field to Update', default=_default_update_field_id, ondelete='cascade')
|
||||
update_related_model_id = fields.Many2one('ir.model', compute='_compute_update_related_model_id')
|
||||
|
||||
value = fields.Text(help="For Python expressions, this field may hold a Python expression "
|
||||
@@ -518,12 +518,12 @@ class IrActionsServer(models.Model):
|
||||
"For Static values, the value will be used directly without evaluation, e.g."
|
||||
"`42` or `My custom name` or the selected record.")
|
||||
evaluation_type = fields.Selection([
|
||||
('value', 'Static value'),
|
||||
('value', 'Custom Value'),
|
||||
('equation', 'Python expression')
|
||||
], 'Value Type', default='value', change_default=True)
|
||||
resource_ref = fields.Reference(
|
||||
string='Record', selection='_selection_target_model', inverse='_set_resource_ref')
|
||||
selection_value = fields.Many2one('ir.model.fields.selection', string="Selection value", ondelete='cascade',
|
||||
selection_value = fields.Many2one('ir.model.fields.selection', string="Custom Value", ondelete='cascade',
|
||||
domain='[("field_id", "=", update_field_id)]', inverse='_set_selection_value')
|
||||
|
||||
value_field_to_show = fields.Selection([
|
||||
|
||||
@@ -1059,8 +1059,10 @@ class IrModelFields(models.Model):
|
||||
|
||||
@api.depends('field_description', 'model')
|
||||
def _compute_display_name(self):
|
||||
IrModel = self.env["ir.model"]
|
||||
for field in self:
|
||||
field.display_name = f'{field.field_description} ({field.model})'
|
||||
model_string = IrModel._get(field.model).name
|
||||
field.display_name = f'{field.field_description} ({model_string})'
|
||||
|
||||
def _reflect_field_params(self, field, model_id):
|
||||
""" Return the values to write to the database for the given field. """
|
||||
|
||||
@@ -333,26 +333,26 @@
|
||||
<group name="action_content">
|
||||
<field name="model_name" invisible="1"/>
|
||||
<field name="available_model_ids" invisible="1"/>
|
||||
<field name="model_id" options="{'no_create': True}" groups="base.group_no_one"
|
||||
<field name="model_id" options="{'no_create': True, 'no_open': True}" groups="base.group_no_one"
|
||||
domain="[('id', 'in', available_model_ids)]"/>
|
||||
<field name="model_id" options="{'no_create': True}" groups="!base.group_no_one" invisible="context.get('default_model_id')"
|
||||
<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}"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
domain="['|', ('model_id', '=', crud_model_id), ('model_id', '=', model_id)]"/>
|
||||
<field name="evaluation_type" invisible="state != 'object_write'"/>
|
||||
<field name="evaluation_type" invisible="state != 'object_write'" widget="radio" options="{'horizontal': True}"/>
|
||||
<field name="value_field_to_show" invisible="1"/>
|
||||
<field name="update_related_model_id" invisible="1"/>
|
||||
<field name="value" invisible="state != 'object_write' or value_field_to_show != 'value' or evaluation_type != 'value'"/>
|
||||
<field name="value" widget="code" options="{'mode': 'python'}" invisible="state != 'object_write' or evaluation_type != 'equation'"/>
|
||||
<field name="resource_ref" string="Value" options="{'model_field': 'update_related_model_id', 'no_create': True}" invisible="state != 'object_write' or value_field_to_show != 'resource_ref' or evaluation_type == 'equation'"/>
|
||||
<field name="selection_value" options="{'no_create': True}" invisible="state != 'object_write' or value_field_to_show != 'selection_value' or evaluation_type == 'equation'"/>
|
||||
<field name="value" invisible="state != 'object_write' or value_field_to_show != 'value' or evaluation_type != 'value'" string="Custom Value"/>
|
||||
<field name="value" widget="code" options="{'mode': 'python'}" invisible="state != 'object_write' or evaluation_type != 'equation'" string="Expression"/>
|
||||
<field name="resource_ref" string="Custom Value" options="{'model_field': 'update_related_model_id', 'no_create': True, 'no_open': True}" invisible="state != 'object_write' or value_field_to_show != 'resource_ref' or evaluation_type == 'equation'"/>
|
||||
<field name="selection_value" options="{'no_create': True, 'no_open': True}" invisible="state != 'object_write' or value_field_to_show != 'selection_value' or evaluation_type == 'equation'"/>
|
||||
|
||||
<field name="type" invisible="1"/>
|
||||
<field name="crud_model_id"
|
||||
options="{'no_create': True}"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
invisible="state != 'object_create'"
|
||||
required="state == 'object_create'"/>
|
||||
<field name="crud_model_name" invisible="1"/>
|
||||
@@ -360,7 +360,7 @@
|
||||
<field name="link_field_id"
|
||||
domain="[('model_id', '=', model_id), ('relation', '=', crud_model_name),
|
||||
('ttype', 'in', ['many2one', 'one2many', 'many2many'])]"
|
||||
options="{'no_create': True}"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
invisible="state != 'object_create'"
|
||||
context="{'default_model_id': model_id, 'default_relation': crud_model_name}"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user