Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2626 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 23
3915
1
ธ.ค. 19
6950
0
ธ.ค. 19
3
1
ต.ค. 23
2078
0
ส.ค. 17
3422