コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2601 ビュー

Hi all, I want to show Popup Message when Save Record with Javascipt ? 
Can you help me! Thanks!

アバター
破棄
最善の回答

Hi,

You can try this code to create a pop-up message when saving a record:


/** @odoo-module **/

import { FormController } from "@web/views/form/form_controller";

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

import { _t } from "@web/core/l10n/translation";

import { useService } from "@web/core/utils/hooks";


patch(FormController.prototype, 'onsave_notification', {

setup() {

this._super(...arguments); // Corrected to pass arguments properly

this.notification = useService("notification");

},

async saveButtonClicked() {

var self = this;

return this._super(...arguments).then(function () {

self.notification.add(_t("Record saved successfully!"), {

title: _t("Success"),

type: "success",

});

});

}

});


Don't forget to add the file path to the assets in your manifest file:

'assets': {

'web.assets_backend': [

'/your_module_name/static/src/js/your_file.js',

],

}


Hope it helps

アバター
破棄
関連投稿 返信 ビュー 活動
2
4月 23
3897
1
12月 19
6938
0
12月 19
3
1
10月 23
2065
0
8月 17
3420