From 1447933f3185695e191e4d64162957a80476e6ac Mon Sep 17 00:00:00 2001 From: Eduard Carrerars Date: Fri, 7 Feb 2025 11:44:17 +0100 Subject: [PATCH] feat(Many2OneSuffix): allow to open in form in a new tab --- src/widgets/base/many2one/Many2oneSuffix.tsx | 16 +++++++++++++++- src/widgets/base/many2one/Many2oneSuffixOoui.tsx | 10 +++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/widgets/base/many2one/Many2oneSuffix.tsx b/src/widgets/base/many2one/Many2oneSuffix.tsx index b88b0c347..4ed57b3cf 100644 --- a/src/widgets/base/many2one/Many2oneSuffix.tsx +++ b/src/widgets/base/many2one/Many2oneSuffix.tsx @@ -32,7 +32,7 @@ export const Many2oneSuffix = (props: Props) => { const tabManagerContext = useContext( TabManagerContext, ) as TabManagerContextType; - const { openRelate } = tabManagerContext || {}; + const { openRelate, openAction } = tabManagerContext || {}; const contentRootContext = useContext( ContentRootContext, @@ -104,6 +104,20 @@ export const Many2oneSuffix = (props: Props) => { }; switch (type) { + case "open": + openAction({ + domain: [["id", "=", id]], + context, + model, + res_id: id, + title: formView?.title || "", + views: [[formView?.view_id, "form"]], + target: "current", + initialView: { type: "form" }, + action_id: -1, + action_type: "ir.actions.act_window", + }); + break; case "action": processAction?.({ actionData: item, diff --git a/src/widgets/base/many2one/Many2oneSuffixOoui.tsx b/src/widgets/base/many2one/Many2oneSuffixOoui.tsx index 4e1033032..038aefbb4 100644 --- a/src/widgets/base/many2one/Many2oneSuffixOoui.tsx +++ b/src/widgets/base/many2one/Many2oneSuffixOoui.tsx @@ -3,6 +3,7 @@ import { PrinterOutlined, ThunderboltOutlined, EnterOutlined, + ExportOutlined, } from "@ant-design/icons"; import { useLocale, @@ -28,7 +29,7 @@ export type ActionRelatePrint = { export type Many2OneSuffixOnItemClickOpts = { item: DropdownMenuItem; - type: "action" | "print" | "relate"; + type: "action" | "print" | "relate" | "open"; }; type Many2oneSuffixProps = { @@ -69,6 +70,11 @@ export const Many2oneSuffixOoui = ({ { sticky: true, items: [ + { + id: "open", + name: t("open"), + icon: , + }, { id: "action", name: t("action"), @@ -104,6 +110,8 @@ export const Many2oneSuffixOoui = ({ setActionModalVisible(true); } else if (item.id === "print") { setPrintModalVisible(true); + } else if (item.id === "open") { + onItemClick?.({ item, type: "open" }); } else { onItemClick?.({ item, type: "relate" }); }