تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
5340 أدوات العرض

under the addons/web/static/src/core/domain_selector/domain_selector_operator_editor.js there is a function 

/** @odoo-module **/

export function getDomainDisplayedOperators(fieldDef) {
if (!fieldDef) {
fieldDef = {};
}
const { type, is_property } = fieldDef;

if (is_property) {
switch (type) {
case "many2many":
case "tags":
return ["in", "not in", "set", "not_set"];
case "many2one":
case "selection":
return ["=", "!=", "set", "not_set"];
}
}

switch (type) {
case "boolean":
return ["is", "is_not"];
case "selection":
return ["=", "!=", "in", "not in", "set", "not_set"];
case "char":
case "text":
case "html":
return ["=", "!=", "ilike", "not ilike", "in", "not in", "set", "not_set"];
case "date":
case "datetime":
return ["=", "!=", ">", ">=", " case "integer":
case "float":
case "monetary":
return [
"=",
"!=",
">",
">=",
" " "between",
"ilike",
"not ilike",
"set",
"not_set",
];
case "many2one":
case "many2many":
case "one2many":
return ["in", "not in", "=", "!=", "ilike", "not ilike", "set", "not_set"];
case "json":
return ["=", "!=", "ilike", "not ilike", "set", "not_set"];
case "properties":
return ["set", "not_set"];
case undefined:
return ["="];
default:
return [
"=",
"!=",
">",
">=",
" " "ilike",
"not ilike",
"like",
"not like",
"=like",
"=ilike",
"child_of",
"parent_of",
"in",
"not in",
"set",
"not_set",
];
}
}

and I want to modify/patch this function (note that this function doesn't belong to any class, and it's used in multiple places) 

I tried to replace it and I got an error

this is my manifest 

'assets': {
'web.assets_frontend': [
('replace', 'web/static/src/core/domain_selector/domain_selector_operator_editor.js', 'my_module/static/src/components/domain_selector/domain_selector_operator_editor.js'),
],
'web._assets_core': [
('replace', 'web/static/src/core/domain_selector/domain_selector_operator_editor.js', 'my_module/static/src/components/domain_selector/domain_selector_operator_editor.js')
],
},

The error


any help!

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

You refer to our blog on

How To Patch Existing OWL Component in Odoo 17


Hope it helps

الصورة الرمزية
إهمال
أفضل إجابة

Based on your code, it seems like you're trying to replace the file in both web.assets_frontend and web._assets_core. This might not be necessary unless you're sure that the file is included in both asset bundles.

    'name': 'My Module',

    'version': '1.0',

    'depends': ['base', 'web'],

    'data': [

        # Your other module data files

    ],

    'assets': {

        'web.assets_frontend': [

            ('replace', 'web/static/src/core/domain_selector/domain_selector_operator_editor.js', 'my_module/static/src/components/domain_selector/domain_selector_operator_editor.js'),

        ],

        'web._assets_core': [

            ('replace', 'web/static/src/core/domain_selector/domain_selector_operator_editor.js', 'my_module/static/src/components/domain_selector/domain_selector_operator_editor.js')

        ],

    },

Make sure that your patched JavaScript file (domain_selector_operator_editor.js) is placed in the correct directory within your module's static folder (my_module/static/src/components/domain_selector/).

After updating your module, you might need to restart your Odoo server and update the assets by running python odoo-bin -c --update=all.


الصورة الرمزية
إهمال
الكاتب

I was confused too, but the file is included in both web.assets_frontend and web._assets_core
'web.assets_frontend': [
'web/static/src/core/**/*',
]
'web._assets_core': [
'web/static/src/core/**/*',
]
So all the core files are in both web.assets_frontend and web._assets_core

أفضل إجابة

Hi 

Check this references

How To Patch Existing OWL Component in Odoo 17


Regards

الصورة الرمزية
إهمال
الكاتب

Thank you, @Mily Shajan
The first argument of the patch method is the class or object that has to be patched; in my case, it's a function rather than a class.

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مايو 24
4158
1
أغسطس 25
2074
2
أبريل 24
1778
2
يوليو 25
2120
2
يوليو 25
1923