diff --git a/addons/crm/__manifest__.py b/addons/crm/__manifest__.py index 6d1a527bb4c..b688d53a110 100644 --- a/addons/crm/__manifest__.py +++ b/addons/crm/__manifest__.py @@ -32,7 +32,6 @@ 'data/crm_team_data.xml', 'data/digest_data.xml', 'data/ir_action_data.xml', - 'data/ir_actions_client_data.xml', 'data/ir_cron_data.xml', 'data/mail_message_subtype_data.xml', 'data/crm_recurring_plan_data.xml', diff --git a/addons/crm/data/ir_actions_client_data.xml b/addons/crm/data/ir_actions_client_data.xml deleted file mode 100644 index 49c1ca38d02..00000000000 --- a/addons/crm/data/ir_actions_client_data.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Add Properties - crm.lead - action_configure_properties_field - - form - - diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index 807238547d7..bca2e13778b 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -252,8 +252,7 @@
- +
diff --git a/addons/fleet/data/fleet_data.xml b/addons/fleet/data/fleet_data.xml index 395c8cd65c4..3f87f150199 100644 --- a/addons/fleet/data/fleet_data.xml +++ b/addons/fleet/data/fleet_data.xml @@ -13,14 +13,6 @@ - - Add Properties - fleet.vehicle - action_configure_properties_field - - form - - New Request 4 diff --git a/addons/fleet/views/fleet_vehicle_views.xml b/addons/fleet/views/fleet_vehicle_views.xml index 474f300d826..84d94c60811 100644 --- a/addons/fleet/views/fleet_vehicle_views.xml +++ b/addons/fleet/views/fleet_vehicle_views.xml @@ -112,8 +112,7 @@
- +
diff --git a/addons/project/__manifest__.py b/addons/project/__manifest__.py index aa37bcfd017..dd2db436234 100644 --- a/addons/project/__manifest__.py +++ b/addons/project/__manifest__.py @@ -24,7 +24,6 @@ 'security/ir.model.access.csv', 'security/ir.model.access.xml', 'data/digest_data.xml', - 'data/ir_actions_client_data.xml', 'report/project_task_burndown_chart_report_views.xml', 'views/account_analytic_account_views.xml', 'views/digest_digest_views.xml', diff --git a/addons/project/data/ir_actions_client_data.xml b/addons/project/data/ir_actions_client_data.xml deleted file mode 100644 index 3cd1414f935..00000000000 --- a/addons/project/data/ir_actions_client_data.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Add Properties - project.task - action_configure_properties_field - - form - - diff --git a/addons/project/views/project_task_views.xml b/addons/project/views/project_task_views.xml index 168c2ebb2dd..a9cf8f9a7fc 100644 --- a/addons/project/views/project_task_views.xml +++ b/addons/project/views/project_task_views.xml @@ -372,8 +372,7 @@
- +
diff --git a/addons/web/static/src/views/fields/properties/properties_field.js b/addons/web/static/src/views/fields/properties/properties_field.js index 7c6c910c8c5..e0e829f3475 100644 --- a/addons/web/static/src/views/fields/properties/properties_field.js +++ b/addons/web/static/src/views/fields/properties/properties_field.js @@ -8,7 +8,7 @@ import { PropertyDefinition } from "./property_definition"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { DropdownItem } from "@web/core/dropdown/dropdown_item"; import { PropertyValue } from "./property_value"; -import { useService } from "@web/core/utils/hooks"; +import { useBus, useService } from "@web/core/utils/hooks"; import { usePopover } from "@web/core/popover/popover_hook"; import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog"; import { reposition } from "@web/core/position_hook"; @@ -30,7 +30,7 @@ export class PropertiesField extends Component { ...standardFieldProps, context: { type: Object, optional: true }, columns: { type: Number, optional: true }, - hideAddButton: { type: Boolean, optional: true }, + showAddButton: { type: Boolean, optional: true }, hideKanbanOption: { type: Boolean, optional: true }, }; @@ -56,10 +56,17 @@ export class PropertiesField extends Component { this.state = useState({ canChangeDefinition: true, movedPropertyName: null, - hideAddButton: this.props.hideAddButton, + showAddButton: this.props.showAddButton, unfoldedSeparators: this._getUnfoldedSeparators(), }); + // Properties can be added from the cogmenu of the form controller + if (this.env.config?.viewType === "form") { + useBus(this.env.model.bus, "PROPERTY_FIELD:ADD_PROPERTY_VALUE", () => { + this.onPropertyCreate(); + }); + } + onWillStart(async () => { await this._checkDefinitionAccess(); }); @@ -609,7 +616,7 @@ export class PropertiesField extends Component { definition_changed: true, }); this.openPropertyDefinition = newName; - this.state.hideAddButton = false; + this.state.showAddButton = true; this.props.record.update({ [this.props.name]: propertiesDefinitions }); } @@ -939,29 +946,10 @@ export const propertiesField = { return { context: dynamicInfo.context, columns: parseInt(attrs.columns || "1"), - hideAddButton: archParseBoolean(attrs.hideAddButton), + showAddButton: archParseBoolean(attrs.showAddButton), hideKanbanOption: archParseBoolean(attrs.hideKanbanOption), }; }, }; registry.category("fields").add("properties", propertiesField); - -/** - * This action is meant to be called from a form client action - * and will let the user create properties, typically used along - * with the "hideAddButton" option of the properties field. - * - * @param {object} env - */ -async function actionAddProperty(env) { - const addProperty = document.querySelector(".o_field_property_add button"); - if (addProperty) { - addProperty.click(); - } else { - const message = _t("You can not create a new property."); - env.services.notification.add(message, { type: "danger" }); - } -} - -registry.category("actions").add("action_configure_properties_field", actionAddProperty); diff --git a/addons/web/static/src/views/fields/properties/properties_field.xml b/addons/web/static/src/views/fields/properties/properties_field.xml index cf48f2ea65c..911b973edf8 100644 --- a/addons/web/static/src/views/fields/properties/properties_field.xml +++ b/addons/web/static/src/views/fields/properties/properties_field.xml @@ -2,7 +2,7 @@
@@ -76,9 +76,9 @@
+ t-att-class="{'g-col-2': props.columns !== 1}">