Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3475 Lượt xem

I want to change web.searchutils const variables such as FIELD_OPERATORS and ... .

I know the way to override a js method but couldn't figure out how to override a variable. replacing the js file completely will also solve my problem but I wasn't able to figure out how. thanks in advance.

the mentioned file is: /addons/web/static/src/legacy/js/control_panel/search_utils.js

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Try like below code

odoo.define('my_module.searchUtils', function (require) {
"use strict";

var searchUtils = require('web.searchUtils')

searchUtils.FIELD_OPERATORS = // What you want

});

Regards

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Unfortunately, there is no easy way to override const variable :(  
Once I was stuck with the same kind of issue, I wanted to add a new date range period so it required overriding YEAR_OPTIONS workaround would override the function which utilizes this const variable

Ảnh đại diện
Huỷ bỏ

if you found any easy way let me know I am curious about it :)

Tác giả

@Ravi Gadhia I wrote the file completely again and replaced it using (
'remove', 'file_path) in the manifest file.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 22
48
1
thg 3 25
4141
0
thg 2 23
2270
0
thg 6 22
2617
3
thg 2 25
14219