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

Hi,

Im trying to extend charfield, but im getting the following error:

The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle:

  • @web/views/fields/char/char_field

The following modules could not be loaded because they have unmet dependencies, this is a secondary error which is likely caused by one of the above problems:

  • @my_module/js/masked_char_field

This is how im trying:

my_module/static/src/js/masked_char_field.js

/** @odoo-module **/

import { registry } from "@web/core/registry";
import { CharField } from "@web/views/fields/char/char_field";


class MaskedCharField extends CharField {
setup() {
super.setup();
console.log("Char field inherited");
}
}
MaskedCharField.supportedTypes = ['char'];
registry.category("fields").add("masked_char_field", MaskedCharField)

__manifest__.py

{
'name': "my_module",
'summary': "short",
'description': "long",
'author': "Me",
'website': "",
'category': 'Localization/Tools',
'version': '0.1',
'depends': ['base', 'web'],
'data': [],
'demo': [],
'assets': {
'web.assets_frontend': [
'my_module/static/src/js/masked_char_field.js'
],
},
'license': 'Other proprietary'
}


what im doing wrong?

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

Yessss! It worked perfectly, thanks!

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

Hi,

You are defining the asset bundle as web.assets_frontend, but you need to use web.assets_backend because Char field is defined in web.assets_backend.


Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
1687
1
thg 5 25
1114
1
thg 7 24
3577
0
thg 8 24
341
1
thg 4 24
2194