Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1337 Переглядів
patch(FormRenderer.prototype, "ob_chatter_position", {

start: function () {
console.log('ob_chatter_position================================')
this._applyFormSizeClass();
return this._super.apply(this, arguments);
},

_applyFormSizeClass: function () {
console.log('applyFormSizeClass')
const formEl = this.$el[0];
if (config.device.size_class <= config.device.SIZES.XS) {
formEl.classList.add('o_xxs_form_view');
} else {
formEl.classList.remove('o_xxs_form_view');
}
},
});

i tried this to override _applyFormSizeClass js function but didn't worked.

Аватар
Відмінити
Найкраща відповідь

n Odoo 16, the method of extending and overriding JavaScript functions has changed. Instead of using patch as you mentioned in your code, you need to define a new JavaScript module and extend the existing class using the extend method. Here's an example of how you can override the _applyFormSizeClass function in Odoo 16:

try this way:
odoo.define('your_module_name.FormRendererExtended', function (require) {
"use strict";

var FormRenderer = require('web.FormRenderer');

FormRenderer.include({
start: function () {
console.log('ob_chatter_position================================');
this._applyFormSizeClass();
return this._super.apply(this, arguments);
},

_applyFormSizeClass: function () {
console.log('applyFormSizeClass');
const formEl = this.$el[0];
if (config.device.size_class <= config.device.SIZES.XS) {
formEl.classList.add('o_xxs_form_view');
} else {
formEl.classList.remove('o_xxs_form_view');
}
},
});

return FormRenderer;
});

Make sure to replace 'your_module_name' with the actual name of your custom module. Then, you can load this JavaScript module in your Odoo module by adding it to the assets section of your module's manifest file (__manifest__.py).

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
трав. 25
2448
1
квіт. 25
3467
1
квіт. 25
4297
1
квіт. 25
1779
4
бер. 25
6885