Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/69723/many2one-suffix-open-tab' …
Browse files Browse the repository at this point in the history
…into v2
  • Loading branch information
ecarreras committed Feb 10, 2025
2 parents 7d58d6e + 1447933 commit 463a6bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/widgets/base/many2one/Many2oneSuffix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion src/widgets/base/many2one/Many2oneSuffixOoui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
PrinterOutlined,
ThunderboltOutlined,
EnterOutlined,
ExportOutlined,
} from "@ant-design/icons";
import {
useLocale,
Expand All @@ -28,7 +29,7 @@ export type ActionRelatePrint = {

export type Many2OneSuffixOnItemClickOpts = {
item: DropdownMenuItem;
type: "action" | "print" | "relate";
type: "action" | "print" | "relate" | "open";
};

type Many2oneSuffixProps = {
Expand Down Expand Up @@ -69,6 +70,11 @@ export const Many2oneSuffixOoui = ({
{
sticky: true,
items: [
{
id: "open",
name: t("open"),
icon: <ExportOutlined />,
},
{
id: "action",
name: t("action"),
Expand Down Expand Up @@ -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" });
}
Expand Down

0 comments on commit 463a6bb

Please sign in to comment.