From 34a1231e2fad65873cb23437c22eaea2134a2f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 5 Mar 2026 18:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E5=AE=9A=E4=BC=9A=E8=AE=AE=E5=8D=A1?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room_booking_gantt_view.js | 38 +++++++++++++++++++ room/views/room_booking_views.xml | 4 ++ 2 files changed, 42 insertions(+) diff --git a/room/static/src/room_booking_gantt_view/room_booking_gantt_view.js b/room/static/src/room_booking_gantt_view/room_booking_gantt_view.js index cbf319d73..9c2c21d88 100644 --- a/room/static/src/room_booking_gantt_view/room_booking_gantt_view.js +++ b/room/static/src/room_booking_gantt_view/room_booking_gantt_view.js @@ -1,7 +1,9 @@ /** @odoo-module **/ +import { _t } from "@web/core/l10n/translation"; import { ganttView } from "@web_gantt/gantt_view"; import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; class RoomBookingGanttController extends ganttView.Controller { /** @@ -30,10 +32,46 @@ class RoomBookingGanttModel extends ganttView.Model { } } +class RoomBookingGanttRenderer extends ganttView.Renderer { + setup() { + super.setup(); + this.userService = useService("user"); + } + + /** + * @override + * 只有系统管理员或会议创建人才显示"编辑"按钮,其他人不显示该按钮。 + */ + getPopoverProps(pill) { + const props = super.getPopoverProps(pill); + const { record } = pill; + const currentUserId = this.userService.userId; + const isAdmin = this.userService.isAdmin; + // organizer_id 是 [id, name] 格式 + const organizerId = record.organizer_id && record.organizer_id[0]; + const isOrganizer = organizerId === currentUserId; + + if (!isAdmin && !isOrganizer) { + // 没有编辑权限,不显示按钮 + const { button: _removed, ...rest } = props; + return rest; + } + // 有权限,按钮文字统一为"编辑" + return { + ...props, + button: { + text: _t("编辑"), + onClick: props.button && props.button.onClick, + }, + }; + } +} + const roomBookingGanttView = { ...ganttView, Controller: RoomBookingGanttController, Model: RoomBookingGanttModel, + Renderer: RoomBookingGanttRenderer, }; registry.category("views").add("room_booking_gantt", roomBookingGanttView); diff --git a/room/views/room_booking_views.xml b/room/views/room_booking_views.xml index 7cb93d3a9..3661914e5 100644 --- a/room/views/room_booking_views.xml +++ b/room/views/room_booking_views.xml @@ -37,6 +37,10 @@
    +
  • + 会议标题: + +
  • 创建人: