Hello,
In Odoo 15, we were overriding a JavaScript function of the web_editor module.
odoo.define('isha_crm.ShowCodeView', function (require) {
"use strict";
var FieldHtml = require('web_editor.field. html'); //it is web_editor.field[dot]html
var fieldRegistry=require('web.field_registry');
alert('Js module registered');
FieldHtml.include({
_onLoadWysiwyg: function () {
alert("This alert was coming in Odoo 15. But not coming now in Odoo 16.");
///My code...
}
});
fieldRegistry.add('html', FieldHtml);
});
The above code was working fine in Odoo 15. But not in Odoo 16.
I am not getting this alert :
alert("This alert was coming in Odoo 15. But not coming now in Odoo 16.");
I tried using the Odoo 16 JavaScript as below :
/** @odoo-module */
import {NewFieldHTML} from '@web_editor/js/backend/field_html';
import {fieldRegistry} from '@web/legacy/js/fields/registry';
export class TemplateFieldHTML extends NewFieldHTML {
setup() {
super.setup();
alert("inside super")
}
_onLoadWysiwyg() {
alert("inside overridden function")
}
}
fieldRegistry.add('template_field_html', TemplateFieldHTML);
The above code says :
Missing dependencies: "@web/legacy/js/fields/registry"
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
Hello Varun,
can you user like this:
import fieldRegistry from 'web.field_registry';
import { FieldHtml } from 'web_editor.field.html'
const TemplateFieldHTML = FieldHtml.extend({
_onLoadWysiwyg() {
}
});
fieldRegistry.add('template_field_html', TemplateFieldHTML);
Note: please use widget='template_field_html' in your field
you can try this way
import fieldRegistry from 'web.field_registry';
import { FieldHtml } from 'web_editor.field.html'
const TemplateFieldHTML = FieldHtml.extend({
_onLoadWysiwyg() {
}
});
fieldRegistry.add('template_field_html', TemplateFieldHTML);
note: please use widget='template_field_html' in your field
Hello Dilip Patel,
Thank you. I used the code shared by you, as below :
/** @odoo-module */
import { fieldRegistry } from 'web.field_registry';
import { FieldHtml } from 'web_editor.field.html';
alert("registering method");
const TemplateFieldHTML = FieldHtml.extend({
_onLoadWysiwyg() {
alert("inside method");
var $button = this._renderTranslateButton();
}
});
fieldRegistry.add('template_field_html', TemplateFieldHTML);
Unfortunately, It's not displaying alert("inside method");
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
0
ม.ค. 25
|
886 | ||
|
2
ก.ค. 24
|
4949 | ||
|
1
เม.ย. 24
|
1971 | ||
|
0
ม.ค. 24
|
1550 | ||
|
0
ม.ค. 24
|
1628 |