Skip to Content
मेन्यू
This question has been flagged
2 Replies
2683 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
1
जून 24
1461
1
मई 24
1959
1
अग॰ 23
2837
2
नव॰ 24
2305
2
जुल॰ 25
443