在视图日历的弹出窗口中添加字段

问题描述 投票:0回答:1

我在 Odoo V17 中有一个自定义模型的日历视图。 我只想在日历弹出窗口中添加更多字段。 enter image description here

这是用于弹出窗口(插件网页)的 xml 文件的一部分:

    <t t-name="web.CalendarCommonPopover.body">
    <ul class="list-group list-group-flush">
        <li t-if="date" class="list-group-item">
            <i class="fa fa-fw fa-calendar text-400" />
            <span class="fw-bold ms-2" t-esc="date" /> <small t-if="dateDuration != 'All day'"><b t-esc="dateDuration" /></small>
        </li>
        <li t-if="time" class="list-group-item">
            <i class="fa fa-fw fa-clock-o text-400" />
            <span class="fw-bold ms-2" t-esc="time" /> <small t-if="timeDuration"><b t-esc="`(${timeDuration})`" /></small>
        </li>
    </ul>
    <ul class="list-group list-group-flush o_cw_popover_fields_secondary">
        <Record resModel="props.model.resModel" resId="props.record.id" fields="props.model.fields" activeFields="activeFields" mode="'readonly'" values="props.record.rawRecord" t-slot-scope="slot">
            <t t-foreach="Object.keys(props.model.popoverFieldNodes)" t-as="fieldId" t-key="fieldId">
                <t t-set="fieldInfo" t-value="props.model.popoverFieldNodes[fieldId]"/>
                <t t-if="!isInvisible(fieldInfo, slot.record)">
                    <li class="list-group-item d-flex text-nowrap align-items-center" t-att-class="fieldInfo.attrs.class"  t-att-data-tooltip="getFormattedValue(fieldId, slot.record)">
                        <span class="fw-bold me-2" t-if="!fieldInfo.options.noLabel">
                            <t t-if="fieldInfo.options.icon">
                                <i t-attf-class="fa-fw {{fieldInfo.options.icon}} text-400" />
                            </t>
                            <t t-else="">
                                <t t-esc="fieldInfo.string" />
                            </t>
                        </span>
                        <div class="flex-grow-1 role-container text-truncate">
                            <Field name="fieldInfo.name" class="'w-100'" record="slot.record" fieldInfo="fieldInfo" type="fieldInfo.widget" />
                        </div>
                    </li>
                </t>
            </t>
        </Record>
    </ul>
</t>

如你所见,它 foreach -> Object.keys(props.model.popoverFieldNodes) 我想,我需要在 popoverFieldNodes 中添加海关字段以在弹出窗口中显示它。

这是来自addon web的js文件'calendar_model'的设置方法:

export class CalendarModel extends Model {
setup(params, services) {
    /** @protected */
    this.user = services.user;

    /** @protected */
    this.keepLast = new KeepLast();

    const formViewFromConfig = (this.env.config.views || []).find((view) => view[1] === "form");
    const formViewIdFromConfig = formViewFromConfig ? formViewFromConfig[0] : false;
    const fieldNodes = params.popoverFieldNodes;
    const { activeFields, fields } = extractFieldsFromArchInfo({ fieldNodes }, params.fields);
    this.meta = {
        ...params,
        activeFields,
        fields,
        firstDayOfWeek: (localization.weekStart || 0) % 7,
        formViewId: params.formViewId || formViewIdFromConfig,
    };

    this.data = {
        filters: {},
        filterSections: {},
        hasCreateRight: null,
        range: null,
        records: {},
        unusualDays: [],
    };
}

但我不明白如何正确添加海关字段。我尝试在 python 中使用 search_read 传递字段,但我认为我需要在 js 中做一些事情来显示它。

你有什么想法吗?

提前致谢:)

javascript python odoo erp odoo-17
1个回答
0
投票

只需将

calendar
类型的视图添加到您的自定义模型中即可。来自 Odoo 本身的模型
calendar.event
的示例(src click):

<record id="view_calendar_event_calendar" model="ir.ui.view">
    <field name="name">calendar.event.calendar</field>
    <field name="model">calendar.event</field>
    <field name="priority" eval="2"/>
    <field name="arch" type="xml">
        <calendar js_class="attendee_calendar" string="Meetings" banner_route="/onboarding/calendar" date_start="start" date_stop="stop" date_delay="duration" all_day="allday"
            event_open_popup="true"
            event_limit="5"
            quick_create="true"
            quick_create_view_id="%(calendar.view_calendar_event_form_quick_create)d"
            color="partner_ids">
            <field name="location" invisible="not location" options="{'icon': 'fa fa-map-marker'}"/>
            <field name="attendees_count" invisible="1"/>
            <field name="accepted_count" invisible="1"/>
            <field name="declined_count" invisible="1"/>
            <field name="user_can_edit" invisible="1"/>
            <field name="partner_ids" options="{'block': True, 'icon': 'fa fa-users'}"
                    filters="1" widget="many2manyattendeeexpandable" write_model="calendar.filters"
                    write_field="partner_id" filter_field="partner_checked" avatar_field="avatar_128"
            />
            <field name="videocall_location" widget="url" text="Join Video Call" options="{'icon': 'fa fa-lg fa-video-camera'}" invisible="not videocall_location"/>
            <field name="is_highlighted" invisible="1"/>
            <field name="is_organizer_alone" invisible="1"/>
            <field name="display_description" invisible="1"/>
            <field name="description" invisible="not display_description" options="{'icon': 'fa fa-bars'}"/>
            <field name="privacy" invisible="1"/>
            <field name="res_model_name" invisible="not res_model_name"
                    options="{'icon': 'fa fa-link', 'shouldOpenRecord': true}"/>
            <field name="alarm_ids" invisible="not alarm_ids" options="{'icon': 'fa fa-bell-o'}"/>
            <field name="categ_ids" invisible="not categ_ids" options="{'icon': 'fa fa-tag', 'color_field': 'color'}"/>
            <!-- For recurrence update Dialog -->
            <field name="recurrency" invisible="1"/>
            <field name="recurrence_update" invisible="1"/>
            <field name="partner_id" string="Organizer" options="{'icon': 'fa fa-user-o'}"/>
        </calendar>
    </field>
</record>

请记住,该示例非常复杂。从简单的开始。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.