/** @odoo-module **/

import { Record } from "@web/model/relational_model/record";
import { patch } from "@web/core/utils/patch";

patch(Record.prototype, {
    _displayInvalidFieldNotification() {
        const fieldNames = [];
        for (const fieldName of this._invalidFields) {
            const fieldDef = this.fields[fieldName];
            const label = fieldDef?.string || fieldName;
            fieldNames.push(`${label} (${fieldName})`);
        }
        const message = fieldNames.length
            ? `Missing required fields:\n${fieldNames.join(", ")}`
            : "Missing required fields (unknown)";
        console.error("FUSION DEBUG:", message, Array.from(this._invalidFields));
        return this.model.notification.add(message, { type: "danger" });
    },
});
