Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1334 Ansichten
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.

Avatar
Verwerfen
Beste Antwort

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).

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Mai 25
2446
1
Apr. 25
3465
1
Apr. 25
4293
1
Apr. 25
1776
4
März 25
6883