Skip to Content
Menu
This question has been flagged
1 Reply
1330 Views
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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
May 25
2441
1
Apr 25
3463
1
Apr 25
4287
1
Apr 25
1775
4
Mar 25
6875