Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1333 Vistas
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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
may 25
2446
1
abr 25
3465
1
abr 25
4293
1
abr 25
1776
4
mar 25
6882