跳至內容
選單
此問題已被標幟
1 回覆
300 瀏覽次數

Hello Odoo Community,

I am working with Odoo 18 and trying to customize the Website Menu Editor. Specifically, I want to add an extra field (e.g., an Image widget ) inside the “Add a Menu Item” dialog box that opens when editing menus in the website backend.

頭像
捨棄
最佳答案

Hii,

To override the Website Menu Editor dialog in Odoo 18 without modifying core addons, you need to extend the existing Owl components used in the website menu editor through a custom module.
Here js file,
/** @odoo-module **/

import { patch } from "@web/core/utils/patch";

import { MenuDialog } from "@website/js/menu/menu_dialog"; // Adjust if path changes


patch(MenuDialog.prototype, {

    setup() {

        this._super();

        this.state.extraImage = null;  // Custom field state

    },


    async saveMenuItem() {

        // Add your custom logic here (e.g., save extraImage)

        console.log("Saving image:", this.state.extraImage);

        await this._super();

    },

});

assets.xml
<odoo>

  <template id="assets_frontend" inherit_id="web.assets_frontend" name="Custom Menu Dialog Patch">

    <xpath expr="." position="inside">

      <script type="module" src="/your_module/static/src/js/menu_dialog_patch.js"/>

    </xpath>

  </template>

</odoo>

頭像
捨棄