Skip to Content
Logo of RG Logo of RG
  • Home
  • Shop
  • Events
  • Courses
  • Company
    • News
    • Success Stories
  • Odoo Docs 19
  • Appointment
  • Jobs
  • Contact us
  • 0
  • 0
  • +1 555-555-5556
  • Sign in
Logo of RG Logo of RG
  • 0
  • 0
    • Home
    • Shop
    • Events
    • Courses
    • Company
      • News
      • Success Stories
    • Odoo Docs 19
    • Appointment
    • Jobs
    • Contact us
  • +1 555-555-5556
  • Sign in
Odoo Docs 19
Home Components Guides Classes Search
418 components
Overlay
  • Accordion Item
  • Barcode Dialog
  • Bottom Sheet
  • Calendar Common Popover
  • Calendar Year Popover
  • Confirmation Dialog
  • Date Time Picker Popover
  • dialog
  • Domain Selector Dialog
  • Dropdown
  • Dropdown Group
  • Dropdown Item
  • Dropdown Popover
  • Error504 Dialog
  • Error Dialog
  • Export Data Dialog
  • Expression Editor Dialog
  • Form Error Dialog
  • Form View Dialog
  • Kanban Column Examples Dialog
  • Kanban Cover Image Dialog
  • Kanban Dropdown Menu Wrapper
  • List Confirmation Dialog
  • Model Field Selector Popover
  • Multi Create Popover
  • Multi Currency Popover
  • popover
  • Redirect Warning Dialog
  • Res User Group Ids Popover
  • Scss Error Display
  • Select Create
  • Select Create Dialog
  • Session Expired Dialog
  • Signature Dialog
  • Warning Dialog
  1. Components
  2. Multi Create Popover
OWL overlay

Multi Create Popover

Odoo 19 OWL component — Multi Create Popover (views)

Live preview Interactive
Source excerpt web/static/src/views/view_components/multi_create_popover.js
import { Component } from "@odoo/owl";
import { _t } from "@web/core/l10n/translation";
import { TimePicker } from "@web/core/time_picker/time_picker";
import { useService } from "@web/core/utils/hooks";
import { Record } from "@web/model/record";
import { useCallbackRecorder } from "@web/search/action_hook";
import { FormRenderer } from "@web/views/form/form_renderer";

export class MultiCreatePopover extends Component {
    static template = "web.MultiCreatePopover";
    static components = {
        FormRenderer,
        Record,
        TimePicker,
    };
    static props = {
        close: Function,
        multiCreateArchInfo: Object,
        multiCreateRecordProps: Object,
        onAdd: Function,
        callbackRecorder: Object,
        timeRange: { type: [Object, { value: null }] },
    };

    setup() {
        this.notification = useService("notification");

        this.multiCreateData = {
            timeRange: this.props.timeRange && { ...this.props.timeRange },
        };
        this.multiCreateArchInfo = this.props.multiCreateArchInfo;
        this.multiCreateRecordProps = {
            ...this.props.multiCreateRecordProps,
            hooks: {
                onRootLoaded: (record) => {
                    this.multiCreateData.record = record;
                },
            },
        };

        useCallbackRecorder(this.props.callbackRecorder, () => this.multiCreateData);
    }

    setMultiCreateTimeRange(timeRange) {
        Object.assign(this.multiCreateData.timeRange, timeRange);
    }

    async isValidMultiCreateData() {
        const isValid = await this.multiCreateData.record.checkValidity({
            displayNotification: true,
        });
        if (!isValid) {
            return false;
        }
        if (this.multiCreateData.timeRange) {
            const { start, end } = this.multiCreateData.timeRange;
            if (!start || !end) {
                this.notification.add(_t("Invalid time range"), {
                    title: "User Error",
                    type: "warning",
                });
                return false;
            }
            if (
                luxon.DateTime.fromObject(start.toObject()) >
                luxon.DateTime.fromObject(end.toObject())
            ) {
                this.notification.add(_t("Start time should be before end time"), {
                    title: "User Error",
                    type: "warning",
                });
                return false;
            }
        }
        return true;
    }

    async onAdd() {
        const isValid = await this.isValidMultiCreateData();
        if (isValid) {
            this.props.onAdd(this.multiCreateData);
            this.props.close();
        }
    }
}
Registry / API
Registry name
MultiCreatePopover
Category
—
Module
web
Slug
multi-create-popover
Nav group
overlay
Follow us

250 Executive Park Blvd, Suite 3400
San Francisco CA 94134

  • +1 555-555-5556
  • info@yourcompany.example.com
Copyright © Company name
Powered by Odoo - The #1 Open Source eCommerce