Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
2676 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvn 24
1459
1
kvě 24
1957
1
srp 23
2833
2
lis 24
2299
2
čvc 25
435