Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
2680 Visualizzazioni

Hello,

When I customize my module, I need to override "SettingsBlock" properties (props). More details, the original code is:

===

SettingsBlock.props = {

    title: { type: String, optional: 1 },

    tip: { type: String, optional: 1 },

    slots: Object,

    class: { type: String, optional: 1 },

};

===

in (web/static/src/webclient/settings_form_view/settings/settings_block.js).

I just want to modify "slots" value (just it). There 2 potential solutions (I think):


1. Create new js in my module and then override entirely SettingsBlock.props, looks like that:

===

SettingsBlock.props = {
...SettingsBlock.props,
slots: { type: Object, optional: 1 },
}

===


2. Use "patch" to avoid all impacts to code base (recommended). However, I don't know how to use. 


Please help. Many thanks.




Avatar
Abbandona
Risposta migliore

The slots like that has it own purpose, i'm guessing you have messed with res.config.setting inheritance and you need to that. Trust me, i have encountered with this when my team somehow mess up with xml of res.config.setting inherit, some of them try to invisible wrong element so it caused error something like "slots bla bla"

Avatar
Abbandona
Risposta migliore

Hi,

We can use the patching method to override a function without changing the source code.For example, use the below code as a reference:

/** @odoo-module **/

import { SettingsBlock } from "@web/webclient/settings/settings_block";

import { patch } from "@web/core/utils/patch";


patch(SettingsBlock.prototype, {    async setup() {

        super.setup(); // By using the super function, we can execute all parent functions along with ours.

    },    settings_block(value){        // you can write your logic here    }

});


Hope it helps.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
giu 24
1459
1
mag 24
1958
1
ago 23
2833
2
nov 24
2299
2
lug 25
435