コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1332 ビュー
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).

アバター
破棄
関連投稿 返信 ビュー 活動
1
5月 25
2444
1
4月 25
3464
1
4月 25
4293
1
4月 25
1776
4
3月 25
6879